xxxxxxxxxx
27
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(400,600);
}
update() {
ellipse(this.x, this.y, 30, 30);
this.y -= 2;
if (this.y<15)
{this.y = 400;}
}
}