-
Notifications
You must be signed in to change notification settings - Fork 0
/
playGame.js
35 lines (35 loc) · 1.17 KB
/
playGame.js
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
function playGame(){
if(current === grid[grid.length-1]){
return 1;
}
else{
document.onkeydown = function(event) {
switch (event.keyCode) {
case 37://left
if(current.walls[3] === false){
current = grid[index(current.i-1, current.j)];
current.highlight();
}
break;
case 38://top
if(current.walls[0] === false){
current = grid[index(current.i, current.j-1)];
current.highlight();
}
break;
case 39://right
if(current.walls[1] === false){
current = grid[index(current.i+1, current.j)];
current.highlight();
}
break;
case 40://bottom
if(current.walls[2] === false){
current = grid[index(current.i, current.j+1)];
current.highlight();
}
break;
}
};
}
}