// Global variable declaration // float minSize; Bubble[] bubbles = new Bubble[50]; int counter; // End Global Variable Declarations // void setup() { size(640,480); frameRate(15); counter = 0; minSize = 10; smooth(); for (int i = 0; i < bubbles.length; i++) { bubbles[i] = new Bubble(color(90,170,256),color(0,0,256),random(-100,-90),random(-100,-90),random(.93,.98),int(random(20,30))); } } void draw() { background(255); for (int i = 0; i < bubbles.length; i++) { if (bubbles[i].popped) { bubbles[i].popped = false; bubbles[i].nsize = bubbles[i].bsize; bubbles[i].xpos = mouseX; bubbles[i].ypos = mouseY; } if (i > 1) { if (dist(bubbles[i].xpos,bubbles[i].ypos,bubbles[i-1].xpos,bubbles[i-1].ypos) < 50) { bubbles[i].popped = true; bubbles[i].nsize = 0; } bubbles[i].pop(); } println("bubble " + i + " at " + bubbles[i].xpos + " " + bubbles[i].ypos + " is " + bubbles[i].popped); if (i > 1) { println("distance from previous bubble is " + dist(bubbles[i].xpos,bubbles[i].ypos,bubbles[i-1].xpos,bubbles[i-1].ypos)); } } println("cycle " + counter); counter++; // if (counter == 10) { // exit(); // } }