xxxxxxxxxx
26
let myRects = [];
function setup() {
createCanvas(600, 400);
for(i=0;i<8;i++) {
myRects[i] = new OverRect();
}
}
function draw() {
background(240);
for(i=0;i<8;i++) {
myRects[i].update();
}
}
class OverRect {
constructor() {
this.x = random(0+20, width-20);
this.y = random(0,15);
}
update() {
ellipse(this.x, this.y, 30, 30);
this.y += 2;
if (this.y > 400)
{this.y = 0;}
}
}