xxxxxxxxxx
49
let bubbles = [];
let round = 1;
function setup() {
createCanvas(600, 400);
for (let i = 0; i<3; i++) {
bubbles[i] = new Bubble(200, 400, 20);
}
}
function draw() {
background(0);
for (let i = 0; i<3; i++) {
bubbles[i].move();
bubbles[i].show();
print(i);
}
round ++;
}
class Bubble {
constructor(x, y, r) {
this.x = x;
this.y = y;
this.r = r;
}
move() {
if (round == 100) {
this.x = random(24, 376);
this.y = random(24, 376);
round = 0;
}
}
show() {
stroke(255);
strokeWeight(4);
noFill();
ellipse(this.x, this.y, this.r*2, this.r*2);
}
}