int maxImages = 6; int imageIndex = 0; boolean buttonr = false; boolean buttonm = false; boolean buttoni = false; boolean buttonv = false; boolean buttonx = false; boolean buttong = false; PImage[] images = new PImage[maxImages]; PFont f; float r = 1; float theta = 0; Radio[] radios = new Radio[150]; Micro [] micros = new Micro [150]; Infra [] infras = new Infra [150]; Violet [] violets = new Violet [200]; Ex [] exes = new Ex [90]; Gamma [] gammas = new Gamma [150]; void setup () { size (800,532); frameRate(4); f = loadFont ( "AmericanTypewriter-16.vlw" ); for (int i = 0; i < images.length; i ++ ) { images[i] = loadImage( "light" + i + ".jpg" ); } for (int i = 0; i < radios.length; i++) { radios [i] = new Radio (random(250,270), random(390,400), random(7,12), 6, random (200,250)); } for (int j = 0; j < micros.length; j++) { micros [j] = new Micro (random(410,460), random(170,210), random(5,11), 7, random (200,250)); } for (int k = 0; k < infras.length; k++) { infras [k] = new Infra (random(460,480), random(330,340), random(4,7), 7, random (200,250)); } for (int l = 0; l < violets.length; l++) { violets [l] = new Violet (random(300,320), random(410,420), random(3,6), 8, random (200,250)); } for (int m = 0; m < exes.length; m++) { exes [m] = new Ex (random(710,770), random(480,510), random(2,5), 9, random (200,230)); } for (int o = 0; o < gammas.length; o++) { gammas [o] = new Gamma (random(645,685), random(280,300), random (2,4), 9, random (255,250)); } } void draw () { background (255); image(images[imageIndex],0,0); imageIndex = (imageIndex + 1) % images.length; textFont (f,16); if (buttonr) { fill (255); } else fill (0); text ("radio", 10,30); if (buttonm) { fill (255); } else fill (0); text ("micro", 10, 60); if (buttoni) { fill (255); } else fill (0); text ("infra", 10,90); if (buttonv) { fill (255); } else fill (0); text ("ultraviolet", 10, 120); if (buttonx) { fill (255); } else fill (0); text ("x", 10, 150); if (buttong) { fill (255); } else fill (0); text ("gamma", 10, 180); if (buttonr) { for (int i = 0; i < radios.length; i++) { radios[i].displayr (); radios[i].mover (); radios[i].bouncer (); } } if (buttonm) { for (int j = 0; j < micros.length; j++) { micros[j].displaym (); micros[j].movem (); micros[j].bouncem (); } } if (buttoni) { for (int k = 0; k < infras.length; k++) { infras[k].displayi (); infras[k].movei (); infras[k].bouncei (); } } if (buttonv) { for (int l = 0; l < violets.length; l++) { violets[l].displayv (); violets[l].movev (); violets[l].bouncev (); } } if (buttonx) { for (int m = 0; m < exes.length; m++) { exes[m].displayx (); exes[m].movex (); exes[m].bouncex (); } } if (buttong) { for (int o = 0; o < gammas.length; o++) { gammas[o].displayg (); gammas[o].moveg (); gammas[o].bounceg (); } } } void mousePressed() { if (mouseX > 5 && mouseX < 60 && mouseY > 20 && mouseY < 45) { buttonr = !buttonr; println (buttonr); } if (mouseX > 5 && mouseX < 60 && mouseY > 50 && mouseY < 75) { buttonm = !buttonm; println (buttonm); } if (mouseX > 5 && mouseX < 60 && mouseY > 80 && mouseY < 105) { buttoni = !buttoni; println (buttoni); } if (mouseX > 5 && mouseX < 75 && mouseY > 110 && mouseY < 135) { buttonv = !buttonv; println (buttonv); } if (mouseX > 5 && mouseX < 60 && mouseY > 140 && mouseY < 165) { buttonx = !buttonx; println (buttonx); } if (mouseX > 5 && mouseX < 60 && mouseY > 170 && mouseY < 200) { buttong = !buttong; println (buttong); } }