p5(sketch => {
let bubble1, bubble2;
sketch.setup = function() {
sketch.createCanvas(width, 400);
bubble1 = new Bubble(200, 200, 20);
bubble2 = new Bubble(400, 200, 60);
};
sketch.draw = function() {
sketch.background(0);
bubble1.move();
bubble1.show();
bubble2.move();
bubble2.show();
};
class Bubble {
constructor(itemX, itemY, itemR) {
this.x = itemX;
this.y = itemY;
this.r = itemR;
}
move() {
this.x = this.x + sketch.random(-5, 5);
this.y = this.y + sketch.random(-5, 5);
}
show() {
sketch.stroke(255);
sketch.strokeWeight(4);
sketch.noFill();
sketch.circle(this.x, this.y, 24);
}
}
})