-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects.js
More file actions
34 lines (28 loc) · 780 Bytes
/
Copy pathobjects.js
File metadata and controls
34 lines (28 loc) · 780 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
function myPoop (posX, posY){
this.x = posX;
this.y = posY;
this.show = function (){
fill(112,53,22);
rect (this.x, this.y, grid, grid);
};
}
function myFood() {
this.x=0;
this.y=0;
this.randomLocation = function(){
this.x = floor(random (0, 600/grid));
this.x *= grid;
this.y = floor(random (0, 600/grid));
this.y *= grid;
for (var i=0; i<snake.tail.length; i++){
if(dist(this.x, this.y, snake.tail[i].x, snake.tail[i].y)<1){
this.randomLocation();
break;
}
}
};
this.show = function (){
fill(255,0,0);
rect (this.x, this.y, grid, grid);
};
}