Add scoring and mine counter

Scoring is a little buggy
This commit is contained in:
synth-ruiner 2015-03-01 16:56:49 +00:00
parent 351e49c5b2
commit 7af5e99f0a
1 changed files with 13 additions and 1 deletions

View File

@ -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 @@
<div id="game"></div>
<div id="stats">
<div id="score">Score: 0</div>
<div id="bombs">Bombs: 0</div>
<div id="bombs" style="display: none;">Bombs: 0</div>
<div id="mines">Mines left: 0</div>
</div>
</body>
</html>