int score; ball[] swarm; int swarmSize; void setup(){ size(700, 500); colorMode(HSB); swarmSize = 10; // Define the size of the swarm swarm = new ball[swarmSize]; for(int i = 0; i < swarmSize; i = i + 1){ swarm[i] = new ball(); // Create the swarm } score = 0; } void draw(){ fill(0, 50); // slight transparency rect(0,0,width,height); for(int i = 0; i < swarmSize; i = i + 1){ swarm[i].display(); // Display each ball swarm[i].update(); // Move each ball } textAlign(CENTER, TOP); fill(255); textSize(30); text("Score: "+score, width/2, 0); } void mouseClicked() { for(int i = 0; i < swarmSize; i = i + 1){ if (swarm[i].mouseOn()) { score += swarm[i].value(); } } }