I’m trying to implement Daniel’s example of the bubbles array and I can’t for the life of me figure out why it’s not working. I should be getting 3 ascending bubbles, but I’m only getting 1, which I suspect might be all 3 on top of each other. Any help would be appreciated!
Bubble Class:
class Bubble {
float x;
float y;
float diameter;
Bubble(float tempD) {
x = random(width);
y = height;
diameter = tempD;
}
void ascend() {
y--;
}
void display() {
stroke(0);
fill(127);
ellipse(x, y, diameter, diameter);
}
}
Bubbles Sketch:
Bubble[] bubbles = new Bubble[2];
int i;
void setup() {
size(640, 360);
for (int i = 0; i < bubbles.length; i++) {
bubbles[i] = new Bubble(30);
}
}
void draw() {
background(255);
fill(0);
for (int i = 0; i < bubbles.length; i++);
{
bubbles[i].ascend();
bubbles[i].display();
}
}