xxxxxxxxxx
33
let w;
class Walker {
constructor() {
this.x = width/2;
this.y = height/2;
}
display() {
stroke(0);
point(this.x, this.y);
}
step() {
let stepx = random(-stepsize, stepsize);
let stepy = random(-stepsize, stepsize);
this.x += stepx;
this.y += stepy;
}
}
function setup() {
createCanvas(400, 400);
w = new Walker();
background(220);
}
function draw() {
w.step();
w.display();
}