File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Open diff view settings
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Open diff view settings
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ SNAKE.Snake = SNAKE.Snake || (function() {
118118 lastMove = 1 ,
119119 preMove = - 1 ,
120120 isFirstMove = true ,
121+ isFirstGameMove = true ,
121122 currentDirection = - 1 , // 0: up, 1: left, 2: down, 3: right
122123 columnShift = [ 0 , 1 , 0 , - 1 ] ,
123124 rowShift = [ - 1 , 0 , 1 , 0 ] ,
@@ -259,10 +260,11 @@ SNAKE.Snake = SNAKE.Snake || (function() {
259260 {
260261 preMove = directionFound ;
261262 }
262- if ( Math . abs ( directionFound - lastMove ) !== 2 && isFirstMove ) // Prevent snake from turning 180 degrees
263+ if ( Math . abs ( directionFound - lastMove ) !== 2 && isFirstMove || isFirstGameMove ) // Prevent snake from turning 180 degrees
263264 {
264265 currentDirection = directionFound ;
265266 isFirstMove = false ;
267+ isFirstGameMove = false ;
266268 }
267269 } ;
268270
@@ -383,6 +385,7 @@ SNAKE.Snake = SNAKE.Snake || (function() {
383385 me . rebirth = function ( ) {
384386 isDead = false ;
385387 isFirstMove = true ;
388+ isFirstGameMove = true ;
386389 preMove = - 1 ;
387390 } ;
388391
You can’t perform that action at this time.
0 commit comments