xxxxxxxxxx
44
var bubbles = [];
function setup() {
createCanvas(windowWidth, windowHeight);
for (var i = 0; i < 100; i++) {
bubbles.push({
x: random(frameCount % 400 + width+ mouseX),
y: random(frameCount % 400 + height),
radius: random(10)
});
}
}
function draw() {
background(50);
noFill();
stroke(255,50);
var w = 10000;
strokeWeight(4 + (frameCount % w));
for (var i = 0; i < bubbles.length; i++) {
var bubble = bubbles[i];
if (dist(mouseX, mouseY, bubble.x, bubble.y) < bubble.radius) {
if (mouseIsPressed) {
bubbles.splice(i, 1); // remove this bubble!
}
fill(255, 200, 200,40);
} else {
fill(255, 200, 200, 200);
}
ellipse(bubble.x, bubble.y, bubble.radius*2);
bubble.x += random(-1,1);
bubble.y += random(-1,1);
}
}