From 7af5e99f0a53acf4cbd3bb4c7781d4b0c524214c Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Sun, 1 Mar 2015 16:56:49 +0000 Subject: [PATCH] Add scoring and mine counter Scoring is a little buggy --- index.html | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 282447d..45f3d63 100644 --- a/index.html +++ b/index.html @@ -136,6 +136,7 @@ var gameBoardWidth = 10; var gameBoardHeight = 9; var score = 0; + var bombs = 1; var firstClick = true; var currentlyIterating = false; var mineChance = 0.2; @@ -247,6 +248,14 @@ inputEnabled = true; } + function updateScore() { + $('#score').text("Score: " + score); + } + + function updateMinesLeft() { + $('#mines').text("Mines left: " + $('.mine:not(.revealed):not(.flagged)').length); + } + $.fn.rowScore = function() { return $(this).children('.mine').length; } @@ -416,6 +425,8 @@ } removeClearedRows(); + updateScore(); + updateMinesLeft(); }); drawGameBoard(); @@ -426,7 +437,8 @@
Score: 0
-
Bombs: 0
+ +
Mines left: 0
\ No newline at end of file