xxxxxxxxxx
30
let bubbles = [];
function setup() {
createCanvas(600, 400);
}
function draw() {
background(0);
for (let bubble of bubbles) {
bubble.draw(255, 4); //Params: strokeColor, strokeWeight
bubble.move();
//This adds hover effect
if (bubble.inside(mouseX, mouseY))
bubble.color = 255;
else
bubble.color = 0;
}
if (bubbles.length > 20)
bubbles.splice(0,1);
}
function mouseDragged() {
bubbles.push(new Bubble(mouseX, mouseY, 40));
}
// function mouseReleased(){
// bubbles = [];
// }