Skip to content

Commit

Permalink
don't use localstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Jun 14, 2022
1 parent d221a12 commit 7f8eba7
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,6 @@ var Game = function ( ) {
this.breakout.setup( this.player, this.enemy );
this.t = 0;
this.score = 100;

if ( localStorage.hiscore == undefined ) localStorage.hiscore = 0;
}

// Creates a new enemy at random
Expand Down Expand Up @@ -888,7 +886,7 @@ var Game = function ( ) {
if ( this.state != 0 ) {
var s = "score: " + this.score;
p1Ctxt.text ( font, p1Ctxt.canvas.width - font.textWidth(s) - 12, 12, s, 0 );
s = "hiscore: " + localStorage.hiscore;
s = "hiscore: " + window.highscores.getScore();
p1Ctxt.text ( font, p1Ctxt.canvas.width - font.textWidth(s) - 12, 12 + font.baselineSkip, s, 0 );
}

Expand Down Expand Up @@ -988,14 +986,11 @@ var Game = function ( ) {
var outcome = this.breakout.update ( t );
if ( outcome == -1 ) { // Player dead
window.highscores.setScore(this.score);
if ( localStorage.hiscore < this.score )
localStorage.hiscore = this.score;
this.transition ( 4 );
sfxLoop.stop();
}

if ( outcome == -2 ) { // Enemy dead
window.highscores.setScore(this.score);
this.loot = new Loot();
this.loot.setup ( this.player, this.enemy );
this.transition ( 2 ); // Transition to loot
Expand All @@ -1004,6 +999,7 @@ var Game = function ( ) {
sfxWin.play();

this.giveScore ( 100 );
window.highscores.setScore(this.score);
}

if ( outcome >= 0 )
Expand Down

0 comments on commit 7f8eba7

Please sign in to comment.