-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWalker.js
More file actions
46 lines (35 loc) · 802 Bytes
/
Walker.js
File metadata and controls
46 lines (35 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function Walker(x, y){
this.x = x;
this.y = y;
}
Walker.prototype.move = function(){
var choice = Math.floor((Math.random() * 4));
// console.log("Moving " + choice);
switch(choice){
case 0:
this.x++;
// console.log("Moving 0 - x:" + this.x);
break;
case 1:
this.x--;
// console.log("Moving 1 - x:" + this.x);
break;
case 2:
this.y++;
// console.log("Moving 2 - y:" + this.y);
break;
case 3:
this.y--;
// console.log("Moving 3 - y:" + this.y);
break;
default:
this.x++;
}
}
Walker.prototype.display = function(){
noStroke(0);
ellipse(this.x, this.y, 5);
}
Walker.prototype.sayHello = function(){
console.log("Hello from Walker!");
}