xxxxxxxxxx
35
let arr = [];
let bob;
function setup() {
createCanvas(400, 400);
background(42);
}
class Bubble {
constructor(diameter){
this.x = mouseX;
this.y = mouseY;
this.diameter = diameter;
}
show(){
circle(this.x, this.y, this.diameter);
}
move(){
this.x += random(-1,1);
this.y += random(-1,1);
}
}
function draw() {
for(let bubble of arr){
bubble.show();
bubble.move();
}
}
function mousePressed() {
bob = new Bubble(random(1,30));
arr.push(bob);
}