int numSpots = 50; int selected = 0; Spot[] spots = new Spot[numSpots]; void setup() { size(500,500); smooth(); noStroke(); for (int i=0; i < numSpots; i++) { spots[i] = new Spot(50+(50*i), 50, 10, i); } } void draw() { fill(0,15); rect(0,0,width,height); fill(255,30); for (int i=0; i < numSpots; i++) { spots[i].move(); spots[i].display(); } } void mousePressed () { spots[selected].start(mouseX, mouseY, mouseX%20, mouseY%20+1); selected++; if (selected >= numSpots) { selected = 0; } } class Spot { float x,y; float diameter; float speed; int direction = 1; Spot(float xpos, float ypos, float dia, float sp) { x = xpos; y = ypos; diameter = dia; speed = sp; } void start(float xpos, float ypos, float dia, float sp) { x = xpos; y = ypos; diameter = dia; speed = sp; } void move() { y += (speed * direction); if ((y > (height - diameter/2)) || (y < diameter/2)) { direction *= -1; } } void display () { ellipse(x, y, diameter, diameter); } }