xxxxxxxxxx
let vecLocation = [];
let vecVelocity = [];
const NUM = 55;
function setup() {
createCanvas(400, 400);
frameRate(60);
for(let i = 0; i < NUM; i++){
vecLocation[i] = createVector(width/2, height/2);
vecVelocity[i] = createVector(random(-10, 10), random(-10, 10));
}
}
function draw() {
background(0);
noStroke();
fill(255);
for(let i = 0; i < NUM; i++){
fill(random(127,250), random(0,127), 0, 250);
ellipse(vecLocation[i].x, vecLocation[i].y, 20, random(0,100));
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;
}
}
}