Merge remote-tracking branch 'origin/master' into gh-pages
This commit is contained in:
commit
ced315a454
57
index.html
57
index.html
|
@ -467,40 +467,26 @@
|
||||||
|
|
||||||
$.fn.getAdjacentTiles = function() {
|
$.fn.getAdjacentTiles = function() {
|
||||||
var adjacentTiles = $('');
|
var adjacentTiles = $('');
|
||||||
|
var x = $(this).getX();
|
||||||
|
var y = $(this).getY();
|
||||||
|
|
||||||
//row above
|
if (y > 0) {
|
||||||
if ($(this).getY() > 0) {
|
var tileAbove = $(this).rowAbove().children().eq(x);
|
||||||
if ($(this).getX() > 0) {
|
|
||||||
adjacentTiles = adjacentTiles.add($(this).rowAbove().children().eq($(this).getX() - 1).toArray());
|
adjacentTiles = adjacentTiles.add(tileAbove.prev());
|
||||||
|
adjacentTiles = adjacentTiles.add(tileAbove );
|
||||||
|
adjacentTiles = adjacentTiles.add(tileAbove.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
adjacentTiles = adjacentTiles.add($(this).rowAbove().children().eq($(this).getX()).toArray());
|
adjacentTiles = adjacentTiles.add($(this).prev());
|
||||||
|
adjacentTiles = adjacentTiles.add($(this).next());
|
||||||
|
|
||||||
if ($(this).getX() < (gameBoardWidth - 1)) {
|
if (y < (gameBoardHeight - 1)) {
|
||||||
adjacentTiles = adjacentTiles.add($(this).rowAbove().children().eq($(this).getX() + 1).toArray());
|
var tileBelow = $(this).rowBelow().children().eq(x);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//this row
|
adjacentTiles = adjacentTiles.add(tileBelow.prev());
|
||||||
if ($(this).getX() > 0) {
|
adjacentTiles = adjacentTiles.add(tileBelow );
|
||||||
adjacentTiles = adjacentTiles.add($(this).prev().toArray());
|
adjacentTiles = adjacentTiles.add(tileBelow.next());
|
||||||
}
|
|
||||||
|
|
||||||
if ($(this).getX() < (gameBoardWidth - 1)) {
|
|
||||||
adjacentTiles = adjacentTiles.add($(this).next().toArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
//row below
|
|
||||||
if ($(this).getY() < (gameBoardHeight - 1)) {
|
|
||||||
if ($(this).getX() > 0) {
|
|
||||||
adjacentTiles = adjacentTiles.add($(this).rowBelow().children().eq($(this).getX() - 1).toArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
adjacentTiles = adjacentTiles.add($(this).rowBelow().children().eq($(this).getX()).toArray());
|
|
||||||
|
|
||||||
if ($(this).getX() < (gameBoardWidth - 1)) {
|
|
||||||
adjacentTiles = adjacentTiles.add($(this).rowBelow().children().eq($(this).getX() + 1).toArray());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return adjacentTiles;
|
return adjacentTiles;
|
||||||
|
@ -596,9 +582,7 @@
|
||||||
//already clicked; use middle click reveal functionality
|
//already clicked; use middle click reveal functionality
|
||||||
|
|
||||||
//number of flags matches number of adjacent mines
|
//number of flags matches number of adjacent mines
|
||||||
$(this).getAdjacentTiles().filter(':not(.flagged, .revealed)').each(function() {
|
$(this).getAdjacentTiles().filter(':not(.flagged, .revealed)').mouseup();
|
||||||
$(this).mouseup();
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
$(this).addClass("revealed");
|
$(this).addClass("revealed");
|
||||||
|
|
||||||
|
@ -620,9 +604,7 @@
|
||||||
$.fn.middleClick = function() {
|
$.fn.middleClick = function() {
|
||||||
//number of flags matches number of adjacent mines
|
//number of flags matches number of adjacent mines
|
||||||
if (parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) {
|
if (parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) {
|
||||||
$(this).getAdjacentTiles().filter(':not(.flagged)').each(function() {
|
$(this).getAdjacentTiles().filter(':not(.flagged, .revealed)').mouseup();
|
||||||
$(this).mouseup();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,7 +662,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
removeClearedRows();
|
removeClearedRows();
|
||||||
//removeClearedColumns();
|
removeClearedColumns();
|
||||||
checkGameOver();
|
checkGameOver();
|
||||||
|
|
||||||
updateScore();
|
updateScore();
|
||||||
|
@ -696,7 +678,7 @@
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date(); a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
|
@ -716,6 +698,7 @@
|
||||||
<p>a game by max bradbury</p>
|
<p>a game by max bradbury</p>
|
||||||
<p>inspirations include minesweeper, tetris and 2048</p>
|
<p>inspirations include minesweeper, tetris and 2048</p>
|
||||||
<p>tell your friends</p>
|
<p>tell your friends</p>
|
||||||
|
<p>stay in school</p>
|
||||||
<button>reset</button>
|
<button>reset</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="setup">
|
<div id="setup">
|
||||||
|
|
Loading…
Reference in New Issue