-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.js
More file actions
48 lines (36 loc) · 779 Bytes
/
Copy pathgenerate.js
File metadata and controls
48 lines (36 loc) · 779 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
46
47
function Cell(){
this.left=true;
this.right=true;
this.up=true;
this.down=true;
}
function Pointer(x,y,direction,maze){
this.x=x;
this.y=y;
this.direction=direction;
this.upNeighbor;
this.downNeighbor;
this.rightNeighbor;
this.leftNeighbor;
this.maze=maze;
}
Pointer.prototype.getNeighbors=function(){
this.upNeighbor=this.maze[this.y-1][this.x];
this.downNeighbor=this.maze[this.y+1][this.x];
this.leftNeighbor=this.maze[this.y][this.x-1];
this.rightNeighbor=this.maze[this.y][this.x+1];
}
function generateMaze(pointer,maze){
pointer.x=5;
pointer.y=5;
}
function generateGrid(gridWidth,gridHeight){
var grid=[];
for(var i=0;i<gridHeight;i++){
grid.push([]);
for(var j=0;j<gridWidth;j++){
grid[i].push(new Cell());
}
}
return grid;
}