public void setup() { size(1024, 768); background(0); frameRate(30); smooth(); drawVectors = false; paused = true; timeline = new Timeline(); sim = new GravitySimulation(); sun = new Star(5000, 25, new PVector(300, 500), new PVector(0, 0), 0, "sun"); planet = new Planet(10, 10, new PVector(500, 500), new PVector(0, 40), "planet"); planet2 = new Planet(50, 10, new PVector(150, 500), new PVector(0, -40), "planet2"); timeline.registerStatefulObject(sun); timeline.registerStatefulObject(planet); timeline.registerStatefulObject(planet2); controlP5 = new ControlP5(this); btnRewind = controlP5.addButton("btnRewind_OnClick", 0, 800, 20, 50, 20); btnRewind.setLabel("Rewind"); btnPlayPause = controlP5.addButton("btnPlayPause_OnClick", 0, 860, 20, 50, 20); btnPlayPause.setLabel("Play"); btnFastForward = controlP5.addButton("btnFastForward_OnClick", 0, 920, 20, 80, 20); btnFastForward.setLabel("Fast Forward"); sliderTimeline = controlP5.addSlider("sliderTimeline_OnClick", 0, 10000, 0, 20, 720, 900, 10); sliderTimeline.setLabel("Timeline"); }
// Event Handlers public void btnPlayPause_OnClick(int theValue) { paused = !paused; if (paused) btnPlayPause.setLabel("Play"); else btnPlayPause.setLabel("Pause"); }