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