xxxxxxxxxx
40
class Ball {
constructor (x, y, size) {
this.x = random (width);
this.y = random (height);
this.size = random (20);
this.color = color (random (255), random (255), random (255));
}
display()
{
fill(this.color);
noStroke();
ellipse (this.x, this.y, this.size, this.size);
}
let bubbles = [];
function setup() {
createCanvas(960, 540);
for(var i = 0; i<10; i++){
let b = new Ball();
bubbles.push(b);
}
}
function draw() {
background(220);
for(let i = 0; i<bubbles.length; i++){
bubbles[i].display();
}
}