xxxxxxxxxx
let num = 2000;
let walker = [];
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
for (let i = 0; i < num; i++) {
walker[i] = new Walker();
}
}
function draw() {
fill(0, 10);
rectMode(CORNER);
rect(0, 0, width, height);
for (let i = 0; i < num; i++) {
walker[i].draw();
}
}
class Walker {
constructor() {
this.vecLocation = createVector(width / 2, height / 2);
}
draw() {
this.vecVelocity = createVector(random(-2, 2), random(-2, 2));
this.vecLocation.add(this.vecVelocity);
noStroke();
fill(255, 127);
rectMode(CENTER);
rect(this.vecLocation.x, this.vecLocation.y, 2, 2);
}
}