You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit df3d88e
Browse filesBrowse the repository at this point in the historyBrowse files
* This method is called when a user presses a key. It logs arrow key presses in "currentDirection", which is used when the snake needs to make its next move.
282
298
* @method handleArrowKeys
@@ -314,15 +330,7 @@ SNAKE.Snake =
314
330
directionFound=MOVE_DOWN;
315
331
break;
316
332
}
317
-
if(currentDirection!==lastMove){
318
-
// Allow a queue of 1 premove so you can turn again before the first turn registers
me.grid[getStartRow()][getStartCol()]=1;// snake head
1024
1044
};
1025
1045
/**
1026
1046
* Gets the current state of the playing board. There are 3 states: 0 - Welcome or Try Again dialog is present. 1 - User has pressed "Start Game" on the Welcome or Try Again dialog but has not pressed an arrow key to move the snake. 2 - The game is in progress and the snake is moving.
@@ -1065,8 +1085,8 @@ SNAKE.Board =
1065
1085
}
1066
1086
elmContainer=myContainer;
1067
1087
elmPlayingField=null;
1068
-
1069
1088
me.setupPlayingField();
1089
+
me.grid[getStartRow()][getStartCol()]=1;// snake head
1070
1090
};
1071
1091
/**
1072
1092
* @method getBoardContainer
@@ -1182,7 +1202,6 @@ SNAKE.Board =
1182
1202
}
1183
1203
}
1184
1204
}
1185
-
me.grid[getStartRow()][getStartCol()]=1;// snake head
1186
1205
1187
1206
myFood.randomlyPlaceFood();
1188
1207
config.onLengthUpdate(1);
@@ -1334,8 +1353,9 @@ SNAKE.Board =
1334
1353
};
1335
1354
1336
1355
me.startAIGame=()=>{
1356
+
me.resetBoard();
1337
1357
mySnake.rebirth();
1338
-
me.setBoardState(2);// start the game!
1358
+
me.setBoardState(BOARD_IN_PLAY);// start the game!
0 commit comments