File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ SNAKE.Snake = SNAKE.Snake || (function() {
127
127
isPaused = false ;
128
128
129
129
// ----- public variables -----
130
-
130
+ me . sessionHighScore = 1 ;
131
131
me . snakeBody = { } ;
132
132
me . snakeBody [ "b0" ] = new SnakeBlock ( ) ; // create snake head
133
133
me . snakeBody [ "b0" ] . row = config . startRow || 1 ;
@@ -324,6 +324,13 @@ SNAKE.Snake = SNAKE.Snake || (function() {
324
324
* @method handleDeath
325
325
*/
326
326
me . handleDeath = function ( ) {
327
+ if ( me . snakeLength > me . sessionHighScore ) me . sessionHighScore = me . snakeLength ;
328
+ function highScoreAlert ( ) {
329
+ document . getElementById ( 'high-score-dialog' ) . innerHTML = 'Your current high score for this session is ' + me . sessionHighScore + '.' ;
330
+ $ ( function ( ) {
331
+ $ ( "#high-score-dialog" ) . dialog ( ) ;
332
+ } ) }
333
+ highScoreAlert ( ) ;
327
334
me . snakeHead . elm . style . zIndex = getNextHighestZIndex ( me . snakeBody ) ;
328
335
me . snakeHead . elm . className = me . snakeHead . elm . className . replace ( / \b s n a k e - s n a k e b o d y - a l i v e \b / , '' )
329
336
me . snakeHead . elm . className += " snake-snakebody-dead" ;
@@ -709,7 +716,6 @@ SNAKE.Board = SNAKE.Board || (function() {
709
716
tmpElm . appendChild ( tryAgainStart ) ;
710
717
return tmpElm ;
711
718
}
712
-
713
719
// ---------------------------------------------------------------------
714
720
// public functions
715
721
// ---------------------------------------------------------------------
@@ -967,4 +973,4 @@ SNAKE.Board = SNAKE.Board || (function() {
967
973
}
968
974
969
975
} ; // end return function
970
- } ) ( ) ;
976
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments