xxxxxxxxxx
let vecLocation = [];
let vecVelocity = [];
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(60);
for (let i = 0; i < 100; i++) {
vecLocation[i] = createVector(width / 2, height / 2);
vecVelocity[i] = createVector(random(-10, 10), random(-10, 10));
}
}
function draw() {
background(0);
fill(0, 127, 255);
for (let i = 0; i < 100; i++)
{
vecLocation[i].add(vecVelocity[i]);
fill(random(0, 255), random(0, 255), random(127, 255), 127);
ellipse(vecLocation[i].x, vecLocation[i].y, random(25,40),random(25,40));
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;
}
}
}