xxxxxxxxxx
29
let bubbles = [];
function setup() {
createCanvas(600, 400);
for (let i = 0; i < 10; i++) {
let x = random(width);
let y = random(height);
let r = random(20, 60);
let b = new Bubble(x, y, r);
bubbles.push(b);
}
}
function mousePressed() {
for (let i = 0; i < bubbles.length; i++) {
if (bubbles[i].clicked(mouseX, mouseY)) {
bubbles.splice(i, 1);
}
}
}
function draw() {
background(255,0,100);
for (let i = 0; i < bubbles.length; i++) {
bubbles[i].move();
bubbles[i].show();
}
}