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