File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,9 @@ class Game {
7171 this . invulnerabilityTime = 2.0 ;
7272 this . invulnerabilityTimer = 0 ;
7373 this . score = 0 ;
74- this . highScore = parseInt ( localStorage . getItem ( 'highScore' ) ) || 0 ;
74+ this . highScore = localStorage . getItem ( 'highScore' )
75+ ? parseInt ( localStorage . getItem ( 'highScore' ) , 10 )
76+ : 0 ;
7577 this . lives = 3 ;
7678
7779 // Initialize music player without starting it
@@ -407,7 +409,7 @@ class Game {
407409 this . score += points ;
408410 if ( this . score > this . highScore ) {
409411 this . highScore = this . score ;
410- localStorage . setItem ( 'highScore' , this . highScore . toString ( ) ) ;
412+ localStorage . setItem ( 'highScore' , this . highScore . toString ( ) ) ; // Store high score to local storage
411413 }
412414 }
413415
You can’t perform that action at this time.
0 commit comments