From b180d92968e8a973bb361be014eb8970d7dc23fb Mon Sep 17 00:00:00 2001 From: Ishaan-11 Date: Sat, 1 Aug 2020 11:45:56 +0530 Subject: [PATCH] added best score feature --- game.js | 5 +++++ index.html | 1 + styles.css | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/game.js b/game.js index a9134a2..bd38102 100644 --- a/game.js +++ b/game.js @@ -6,6 +6,7 @@ var userClickedPattern = []; var started = false; var level = 0; +var bestScore = 0; $(document).keypress(function() { if (!started) { @@ -30,6 +31,10 @@ function checkAnswer(currentLevel) { if (gamePattern[currentLevel] === userClickedPattern[currentLevel]) { if (userClickedPattern.length === gamePattern.length){ + if (bestScore < level) { + bestScore = level; + $("#best-score span").text(bestScore); + } setTimeout(function () { nextSequence(); }, 1000); diff --git a/index.html b/index.html index 659acb5..24e9095 100644 --- a/index.html +++ b/index.html @@ -10,6 +10,7 @@

Press A Key to Start

+

Best Score: 0

diff --git a/styles.css b/styles.css index 6edc539..2fd39b2 100644 --- a/styles.css +++ b/styles.css @@ -10,6 +10,13 @@ body { color: #FEF2BF; } +#best-score { + font-family: 'Press Start 2P', cursive; + font-size: 2rem; + margin: 2%; + color: #FEF2BF; +} + .container { display: block; width: 50%;