xxxxxxxxxx
34
// https://bit.ly/2wNJsCi
const num = 500;
let walker = [];
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(60);
for (let i = 0; i < num; i++) {
walker[i] = new Walker();
}
background(0);
}
function draw() {
background(0, 5);
for (let i = 0; i < num; i++) {
walker[i].draw();
}
}
class Walker {
constructor() {
this.position = createVector(width / 2, height / 2);
}
draw() {
for (let i = 0; i < 10; i++) {
this.velocity = createVector(random(-1, 1), random(-1, 1));
this.position.add(this.velocity);
noStroke();
fill(255);
circle(this.position.x, this.position.y, 2);
}
}
}