xxxxxxxxxx
let vecLoc = [];
let vecVel = [];
const num = 100;
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(30);
background(255);
for(let i = 0; i<num; i++){
vecLoc[i] = createVector(width/2, height/2);
vecVel[i] = createVector(random(-10,10),random(-10,10));
}
}
function draw() {
noStroke();
for(let i = 0; i<num; i++){
fill(random(255),random(255),random(255),random(200));
ellipse(vecLoc[i].x,vecLoc[i].y,random(100),random(100));
vecLoc[i].add(vecVel[i]);
if(vecLoc[i].x > width || vecLoc[i].x < 0){
vecLoc[i] = createVector(width/2, height/2);
}
if(vecLoc[i].y > width || vecLoc[i].y < 0){
vecLoc[i] = createVector(width/2, height/2);
}
}
}