Merge remote-tracking branch 'origin/master' into gh-pages

This commit is contained in:
synth-ruiner 2015-03-17 19:10:44 +00:00
commit 5ef018e8ac
1 changed files with 77 additions and 40 deletions

View File

@ -16,6 +16,7 @@
} }
* { * {
box-sizing: border-box;
font-family: Helsinki; font-family: Helsinki;
} }
@ -45,8 +46,8 @@
background-color: #1b1c17; background-color: #1b1c17;
float: left; float: left;
margin: 0 auto; margin: 0 auto;
height: 9em; /* fallback */ height: 100%;
height: 100vh - 10vmin; overflow: hidden;
} }
#stats { #stats {
@ -118,9 +119,9 @@
} }
#setup div.centre { #setup div.centre {
position: absolute; text-align: center;
left: 1em; /* fallback */ margin-top: 0.2em; /* fallback */
left: 10vmin; margin-top: 2vmin;
} }
input[type="radio"] { input[type="radio"] {
@ -149,12 +150,6 @@
box-shadow: 1vmin 1vmin 0 #000; box-shadow: 1vmin 1vmin 0 #000;
border: none; border: none;
position: absolute;
left: 3.8em; /* fallback */
left: 38vmin;
top: 7.5em; /* fallback */
top: 75vmin;
background: #768087; background: #768087;
background: -moz-linear-gradient(top, #768087 0%, #53595e 100%); background: -moz-linear-gradient(top, #768087 0%, #53595e 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#768087), color-stop(100%,#53595e)); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#768087), color-stop(100%,#53595e));
@ -193,6 +188,7 @@
list-style-type: none; list-style-type: none;
padding: 0; padding: 0;
margin: 0; margin: 0;
overflow: hidden;
} }
li { li {
@ -208,10 +204,10 @@
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
float: left; float: left;
height: 0.8em; /* fallback */ height: 1em; /* fallback */
height: 8vmin; height: 10vmin;
width: 0.8em; /* fallback */ width: 1em; /* fallback */
width: 8vmin; width: 10vmin;
background-color: #454e52; background-color: #454e52;
border-radius: 0.2em; /* fallback */ border-radius: 0.2em; /* fallback */
border-radius: 2vmin; border-radius: 2vmin;
@ -364,6 +360,10 @@
return $(this).checkRow(); return $(this).checkRow();
}); });
if (rowsToRemove.length > 0) {
suddenDeath();
}
rowsToRemove.each(function() { rowsToRemove.each(function() {
score += $(this).children('.mine').length; score += $(this).children('.mine').length;
@ -388,15 +388,16 @@
return $(this).checkColumn(); return $(this).checkColumn();
}); });
if (columnsToRemove.length > 0) {
suddenDeath();
}
columnsToRemove.each(function() { columnsToRemove.each(function() {
score += $(this).column().filter('.mine').length; score += $(this).column().filter('.mine').length;
$(this).column().addClass("removing"); $(this).column().addClass("removing");
//animation for top row + deletion //animation for top row + deletion of column
// then animation for others?
//...
$(this).animate({width: 0, borderRadius: 0, padding: 0}, "slow", function() { $(this).animate({width: 0, borderRadius: 0, padding: 0}, "slow", function() {
$(this).column().remove(); $(this).column().remove();
$('ul').each(function() { $('ul').each(function() {
@ -409,6 +410,7 @@
$('li.revealed:not(.mine, .removing):empty').mouseup(); $('li.revealed:not(.mine, .removing):empty').mouseup();
}); });
//then just animation for others
$(this).column().animate({width: 0, borderRadius: 0, padding: 0}, "slow"); $(this).column().animate({width: 0, borderRadius: 0, padding: 0}, "slow");
}); });
} }
@ -426,6 +428,8 @@
/mines[0-9]/, "mines" + mineCount /mines[0-9]/, "mines" + mineCount
) )
); );
$(this).removeClass("mines mines0");
}); });
} }
@ -434,7 +438,10 @@
} }
function isGameOver() { function isGameOver() {
return ($('ul').has('.mine.revealed').length == gameBoardHeight); return $('ul').has('.mine.revealed').length == gameBoardHeight
&& $('ul').first().children().filter(function() {
return $(this).column().filter('.mine.revealed').length > 0;
}).length == gameBoardWidth;
} }
function checkGameOver() { function checkGameOver() {
@ -497,6 +504,33 @@
return column; return column;
} }
window.oneColumnLeft = function() {
return $('ul').first().children().filter(function() {
return $(this).column().filter('.mine:not(.revealed, .flagged)').length == 0;
}).length >= (gameBoardWidth - 1)
}
window.oneRowLeft = function() {
return $('ul').filter(function() {
return $(this).children('.mine:not(.revealed, .flagged)').length == 0;
}).length >= (gameBoardHeight - 1);
}
window.isSuddenDeath = function() {
return oneRowLeft() && oneColumnLeft();
}
window.suddenDeath = function() {
if (isSuddenDeath()) {
mineChance += 0.01;
//don't want the chance to get to 100% because that's completely predictable
if (mineChance > 0.8) {
mineChance = 0.8;
}
}
}
$.fn.getX = function() { $.fn.getX = function() {
return $(this).index(); return $(this).index();
} }
@ -587,6 +621,9 @@
//reset stats //reset stats
firstClick = true; firstClick = true;
//reset difficulty
$('input:checked').change();
score = 0; score = 0;
updateScore(); updateScore();
@ -688,22 +725,21 @@
if (mouseHeld) { if (mouseHeld) {
mouseHeld = false; mouseHeld = false;
return; } else {
} switch (event.which) {
case 3:
switch (event.which) { $(this).rightClick();
case 3: break;
$(this).rightClick(); case 2:
break; $(this).middleClick();
case 2: break;
$(this).middleClick(); case 1:
break; $(this).leftClick();
case 1: break;
$(this).leftClick(); default:
break; $(this).leftClick(true); //automated
default: break;
$(this).leftClick(true); //automated }
break;
} }
removeClearedRows(); removeClearedRows();
@ -749,7 +785,6 @@
<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">
@ -758,7 +793,7 @@
<p> <p>
<strong>left click</strong> or <strong>tap</strong> to clear a tile. <br> <strong>left click</strong> or <strong>tap</strong> to clear a tile. <br>
<strong>right click</strong> or <strong>hold</strong> to flag a mine. <br> <strong>right click</strong> or <strong>hold</strong> to flag a mine. <br>
rows with <strong>exploded mines</strong> cannot be cleared. rows and columns with <strong>exploded mines</strong> cannot be cleared.
</p> </p>
<h2>Difficulty</h2> <h2>Difficulty</h2>
@ -772,8 +807,10 @@
<label for="difficultyHard">Hard</label> <label for="difficultyHard">Hard</label>
</div> </div>
<button class="start">start</button> <div class="centre">
<button class="cancel">cancel</button> <button class="start">start</button>
<button class="cancel">cancel</button>
</div>
</div> </div>
</body> </body>
</html> </html>