xxxxxxxxxx
53
let walkers;
function setup() {
background(200);
noStroke();
createCanvas(800, 400);
walkers = [];
for (let i = 0; i < 20; i++) {
walkers.push(new Walker(random(0, width), random(0, height), random(1, 1), random(1, 4)));
}
}
function draw() {
for(let i=0; i<4; i++){
for (let i = 0; i < walkers.length; i++) {
walkers[i].display();
walkers[i].move();
}
}
}
class Walker {
constructor(tx, ty, tsize, tspeed) {
//width and height
this.x = tx;
this.y = ty;
this.size = tsize;
this.speed = tspeed;
//this.c =color(ceil(random(0,255)),ceil(random(0,255)),ceil(random(0,255)));
this.c =color(100,200,300);
}
display() {
//fill(this.color);
fill(30);
ellipse(this.x, this.y, this.size, this.size);
}
move() {
this.x += (random(this.speed * -1, this.speed));
this.y += (random(this.speed * -1, this.speed));
}
}