xxxxxxxxxx
38
let w;
class Walker {
constructor() {
this.x = width/2;
this.y = height/2;
}
display() {
stroke(0);
point(this.x, this.y);
}
step() {
let choice = floor(random(4));
let valueStep = randomGaussian(2, 5);
if (choice === 0 ){
this.x+=valueStep;
} else if (choice === 1) {
this.x-=valueStep;
} else if (choice === 2) {
this.y+=valueStep;
} else {
this.y-=valueStep;
}
}
}
function setup() {
createCanvas(400, 400);
w = new Walker();
background('#F7F7F7');
}
function draw() {
w.step();
w.display();
}