I need help understanding the Challenge: Up Walker (ADVANCED JS: NATURAL STIMULATIONS)
Hi, I'm having a hard time figuring out Step 1 of the challenge. Here is my code so far:
var Walker = function() {
this.x = width/2;
this.y = height/2;
};
Walker.prototype.display = function() {
stroke(0, 0, 0);
point(this.x, this.y);
};
// Randomly move right, left, down or up
Walker.prototype.walk = function() {
var r = random(1);
if (r < 0.1) {
this.x++;
} else if (r < 0.1) {
this.x--;
} else if (r < 0.6) {
this.y++;
} else {
this.y--;
}
};
var w = new Walker();
draw = function() {
w.walk();
w.display();
};
Thanks!
Log ind for at efterlade en kommentar.