Skip to content

Instantly share code, notes, and snippets.

@shohan4556
Created December 19, 2021 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shohan4556/e61a71f7de3d655ae7c4677e082cfcb4 to your computer and use it in GitHub Desktop.
Save shohan4556/e61a71f7de3d655ae7c4677e082cfcb4 to your computer and use it in GitHub Desktop.
simple highscore
// save score for the first time
if (localStorage.hasOwnProperty("score") == false) {
localStorage.setItem("score", this.SCORE);
} else {
const savedScore = localStorage.getItem("score");
if (this.SCORE > savedScore) {
localStorage.setItem("score", this.SCORE);
}
}
this.scene.start("gameover", { currentScore: this.SCORE });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment