Skip to content

Commit 97d7ee2

Browse files
committed
added premoveOnPause config option
1 parent a597378 commit 97d7ee2

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎js/init.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var mySnakeBoard = new SNAKE.Board({
22
boardContainer: "game-area",
3-
fullScreen: true
3+
fullScreen: true,
4+
premoveOnPause: false
45
});

‎js/snake.js‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ SNAKE.Snake = SNAKE.Snake || (function() {
249249
2
250250
*/
251251
me.handleArrowKeys = function(keyNum) {
252-
if (isDead || (isPaused && false)) {return;}
252+
if (isDead || (isPaused && !config.premoveOnPause)) {return;}
253253

254254
var snakeLength = me.snakeLength;
255255

@@ -721,9 +721,9 @@ SNAKE.Board = SNAKE.Board || (function() {
721721
elmContainer.appendChild(elmTryAgain);
722722
elmContainer.appendChild(elmWin);
723723

724-
mySnake = new SNAKE.Snake({playingBoard:me,startRow:2,startCol:2});
724+
mySnake = new SNAKE.Snake({playingBoard:me,startRow:2,startCol:2,premoveOnPause: config.premoveOnPause});
725725
myFood = new SNAKE.Food({playingBoard: me});
726-
726+
727727
elmWelcome.style.zIndex = 1000;
728728
}
729729
function maxBoardWidth() {
@@ -1077,6 +1077,7 @@ SNAKE.Board = SNAKE.Board || (function() {
10771077
config.left = (typeof config.left === "undefined") ? 0 : config.left;
10781078
config.width = (typeof config.width === "undefined") ? 400 : config.width;
10791079
config.height = (typeof config.height === "undefined") ? 400 : config.height;
1080+
config.premoveOnPause = (typeof config.premoveOnPause === "undefined") ? false : config.premoveOnPause;
10801081

10811082
if (config.fullScreen) {
10821083
SNAKE.addEventListener(window,"resize", function() {

0 commit comments

Comments
 (0)