xxxxxxxxxx
let vecLocation=[];
let vecVelocity=[];
const NUM=50;
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(20);
for(let i=0;i<NUM;i++){
vecLocation[i]=createVector(width/2,0);
vecVelocity[i]=createVector(random(-10,10),random(-10,10))
}
}
function draw() {
rect(0,0,100,100);
background(30,120,90);
noStroke();
fill(random(200,255),random(200,255),random(255),220);
for(let i=0;i<NUM;i++){
ellipse(vecLocation[i].x,vecLocation[i].y,30,random(10,60));
vecLocation[i].add(vecVelocity[i])
if(vecLocation[i].x>width || vecLocation[i].x<0){
vecVelocity[i].x=vecVelocity[i].x*-1;
}
if(vecLocation[i].y>height || vecLocation[i].y<0){
vecVelocity[i].y=vecVelocity[i].y*-1;
}
}
}