xxxxxxxxxx
let vecLocation = [];
let vecVelocity = [];
const num = 100;
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(60);
a = random(10, 30);
b = random(1, 195);
c = random(1, 195);
d = random(1, 195);
for(let i = 0; i < num; i++) {
vecLocation[i] = createVector(random(0, windowWidth), random(0, windowHeight));
vecVelocity[i] = createVector(random(-10, 10), random(-10, 10));
}
}
function draw() {
background(0);
noStroke();
fill(b, c, d);
for(let i = 0; i < num; i++) {
ellipse(vecLocation[i].x, vecLocation[i].y, a, a);
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;
}
}
}