High scores
This commit is contained in:
parent
782172c4a7
commit
8d74d5c366
15
index.html
15
index.html
|
@ -485,8 +485,22 @@
|
|||
if (isGameOver()) {
|
||||
$('#gameOver').show();
|
||||
|
||||
var currentHiScore = 0;
|
||||
|
||||
if ($.isNumeric(localStorage.getItem("hiscore"))) {
|
||||
currentHiScore = parseInt(localStorage.getItem("hiscore"));
|
||||
}
|
||||
|
||||
if (score > currentHiScore) {
|
||||
currentHiScore = score;
|
||||
}
|
||||
|
||||
$('#gameOver .score').text(score);
|
||||
$('#gameOver .hiscore').text(currentHiScore);
|
||||
|
||||
//clear saved game
|
||||
localStorage.clear();
|
||||
localStorage.setItem("hiscore", currentHiScore);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -832,6 +846,7 @@
|
|||
<div id="game"></div>
|
||||
<div id="gameOver">
|
||||
<h1>game over</h1>
|
||||
<p>score: <span class="score"></span> personal best: <span class="hiscore"></span></p>
|
||||
<p>a game by max bradbury</p>
|
||||
<p>inspirations include minesweeper, tetris and 2048</p>
|
||||
<p>tell your friends</p>
|
||||
|
|
Loading…
Reference in New Issue