import noc.*; import java.util.*; // import java.lang.*; import processing.opengl.*; //public class nebula_cloud extends PApplet{ //Make Your Own Solar System System solarSystem; int removalIndex = -1; boolean dragging = false; Button asteroidButton; long timer; Button resetButton; Button titleButton; Button sunToggleButton; Button nebulaButton; void setup(){ // println(cbrt(10)); //size(640,480, OPENGL); size(640,480); smooth(); fill(0,0,20); rect(0,0,width,height); frameRate(30); // slider = new Slider(width - 50, height/2 - 50,0.5); // lastSlider = 0.5; solarSystem = new System(false); titleButton = new Button(width/2 - 198,10,254,23,"click in the sky to make a planet",16); asteroidButton = new Button(width - 120, height - 180, 100,70, "asteroid" + "\n" + "storm", 28); nebulaButton = new Button(width - 120, height - 270, 100,70, "nebula" + "\n" + "cloud", 28); resetButton = new Button(width - 120, height - 90, 100,70, "reset", 40); sunToggleButton = new Button(width - 120, height - 360, 100,70, "toggle" + "\n" + "number of" + "\n" + "suns", 15); } void draw(){ if (dragging){ background(0,0,20); } else{ fill(0,0,20,100); rect(0,0,width,height); } if (!dragging){ solarSystem.compare(); } solarSystem.display(); fill(50); rect(width-140,0,140,height); //i should make a class for managing buttons asteroidButton.display(); resetButton.display(); titleButton.display(); sunToggleButton.display(); nebulaButton.display(); } void mouseDragged(){ dragging = true; solarSystem.drag(); } void mouseReleased(){ if (!dragging){ if (mouseX < width - 140){ solarSystem.addPlanet(mouseX, mouseY); } if (asteroidButton.inButton(mouseX, mouseY)){ solarSystem.addAsteroids(); } if (nebulaButton.inButton(mouseX, mouseY)){ solarSystem.reset(); solarSystem.nebula(); } if (resetButton.inButton(mouseX, mouseY)){ solarSystem.reset(); solarSystem.setSuns(); } if (sunToggleButton.inButton(mouseX, mouseY)){ solarSystem.toggleSuns(); } } dragging = false; } // }