xxxxxxxxxx
let num = 1000;
let vecLocation = [];
let vecVelocity = [];
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(random(1000));
for (let i = 0; i < num; i++){
vecLocation[i] = createVector(0, 0);
vecVelocity[i] = createVector(random(-20,20), random(-20,20));
}
}
function draw() {
background(0);
noStroke();
fill(random(255), random(30), 155);
for (let i = 0; i < num; i++){
vecLocation[i].add(vecVelocity[i]);
ellipse(vecLocation[i].x, vecLocation[i].y, random(7), random(7));
if (vecLocation[i].x < 0 || vecLocation[i].x > width){
vecVelocity[i].x = vecVelocity[i].y * random(-4,-1);
}
if (vecLocation[i].y < 0 || vecLocation[i].y > height){
vecVelocity[i].y = vecVelocity[i].y * random(-2,-1);
}
}
}