From 8d74d5c36605caedc68f872acc04a0815f44d2c2 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Wed, 18 Mar 2015 20:41:42 +0000 Subject: [PATCH] High scores --- index.html | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/index.html b/index.html index 518becf..6f2f194 100644 --- a/index.html +++ b/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 @@

game over

+

score: personal best:

a game by max bradbury

inspirations include minesweeper, tetris and 2048

tell your friends