File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 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() {
127127 isPaused = false ;
128128
129129 // ----- public variables -----
130-
130+ me . sessionHighScore = 1 ;
131131 me . snakeBody = { } ;
132132 me . snakeBody [ "b0" ] = new SnakeBlock ( ) ; // create snake head
133133 me . snakeBody [ "b0" ] . row = config . startRow || 1 ;
@@ -324,6 +324,13 @@ SNAKE.Snake = SNAKE.Snake || (function() {
324324 * @method handleDeath
325325 */
326326 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 ( ) ;
327334 me . snakeHead . elm . style . zIndex = getNextHighestZIndex ( me . snakeBody ) ;
328335 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 / , '' )
329336 me . snakeHead . elm . className += " snake-snakebody-dead" ;
@@ -709,7 +716,6 @@ SNAKE.Board = SNAKE.Board || (function() {
709716 tmpElm . appendChild ( tryAgainStart ) ;
710717 return tmpElm ;
711718 }
712-
713719 // ---------------------------------------------------------------------
714720 // public functions
715721 // ---------------------------------------------------------------------
@@ -967,4 +973,4 @@ SNAKE.Board = SNAKE.Board || (function() {
967973 }
968974
969975 } ; // end return function
970- } ) ( ) ;
976+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments