xxxxxxxxxx
let vecLocation=[];
let vecVelocity=[];
const NUM=1000;
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(60);
for(let i=0;i<NUM;i++) {
vecLocation[i]=createVector(random(width),windowHeight);
vecVelocity[i]=createVector(0,random(-10,-20));
}
}
function draw() {
background(141,163,196);
noStroke();
fill(225);
for(let i=0;i<NUM;i++) {
ellipse(vecLocation[i].x,vecLocation[i].y,10,10);
vecLocation[i].add(vecVelocity[i]);
if(vecLocation[i].y<0 || vecLocation[i].y>height) {
vecVelocity[i].y=vecVelocity[i].y * -0.5;
}
}
}