xxxxxxxxxx
let num =25;
let vecLocation=[];
let vecVelocity=[];
function setup() {
createCanvas(windowWidth,windowHeight);
frameRate(30);
for(let i = 0;i<num;i++){
vecLocation[i] =createVector(random(0,windowWidth),random(0,windowHeight));
}
}
function draw() {
background(72,61,110);
noStroke();
fill(238,173,14,random(30,200));
for(let i =0;i<num;i++){
let size=random(2,20)
vecVelocity[i] =createVector(random(-10,10),random(-3,3));
vecLocation[i].add(vecVelocity[i]);
ellipse(vecLocation[i].x,vecLocation[i].y,size,size);
if(vecLocation[i].x<0||vecLocation[i].x>width){
vecVelocity[i].x=vecVelocity[i].x*-1;}
if(vecLocation[i].y<0||vecLocation[i].y>height){
vecVelocity[i].y=vecVelocity[i].y*-1;}
}
}