From cebae1734160889f5c21d8dda1e41574bf48e5d4 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 09:40:32 +0000 Subject: [PATCH 01/12] Add middle-click functionality to left click --- index.html | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index f9707a5..427877d 100644 --- a/index.html +++ b/index.html @@ -468,7 +468,9 @@ $('#setup').hide(); }); - $.fn.leftClick = function() { + $.fn.leftClick = function(automated) { + if (!automated) automated = false; + //don't want first click to be a mine if (firstClick) { var x = $(this).getX(); @@ -500,9 +502,11 @@ //$(this).middleClick(); //number of flags matches number of adjacent mines - $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { - //$(this).mousedown(); - }); + if (!automated && parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { + $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { + $(this).mousedown(); + }); + } } else { $(this).addClass("revealed"); @@ -522,8 +526,6 @@ } $.fn.middleClick = function() { - //move this functionality to left click - //number of flags matches number of adjacent mines if (parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { @@ -558,9 +560,11 @@ $(this).middleClick(); break; case 1: - default: $(this).leftClick(); break; + default: + $(this).leftClick(true); //automated + break; } removeClearedRows(); From 0272c62f6c5e3d752a99627f36c408eb16780d5c Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 09:41:55 +0000 Subject: [PATCH 02/12] Update readme --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 3f7d639..ad09561 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Rows with exploded mines cannot be cleared. See how far you can get! Left-click to clear a tile. Right-click to flag a mine. Middle-click a number to clear any non-flagged adjacent tiles. ## stuff to add -move middle-click functionality to left-click instead - add support for mobile devices/1-button mice (probably hold down to flag a mine) save game using html5 local storage so player can come back later From b4a037c0cb94ee9634353310f632e921f8a804b7 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 10:41:53 +0000 Subject: [PATCH 03/12] Mouse hold functionality --- index.html | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index 427877d..c961122 100644 --- a/index.html +++ b/index.html @@ -217,6 +217,9 @@ var currentlyIterating = false; var mineChance = 0.2; var inputEnabled = true; + var clickholdMs = 200; + var timeout; //hold timer + var mouseHeld = false; $(document).ready(function() { function drawGameBoard() { @@ -309,10 +312,10 @@ }); //refresh last row to reflect new rows beneath - $('li.revealed').last().parent().children('li.revealed').mousedown(); + $('li.revealed').last().parent().children('li.revealed').mouseup(); //click blank tiles - $('li.revealed:not(.mine):empty').mousedown(); + $('li.revealed:not(.mine):empty').mouseup(); //this is a bit of a hack :( oh well $('ul:gt(' + gameBoardHeight + ')').remove(); @@ -497,16 +500,13 @@ //game over, or lose a life, or whatever //... - } else if (parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged').length) { + } else if (!automated && parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { //already clicked; use middle click reveal functionality - //$(this).middleClick(); - + //number of flags matches number of adjacent mines - if (!automated && parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { - $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { - $(this).mousedown(); - }); - } + $(this).getAdjacentTiles().filter(':not(.flagged, .revealed)').each(function() { + $(this).mouseup(); + }); } else { $(this).addClass("revealed"); @@ -518,7 +518,7 @@ //if no mines adjacent, cascade! if ($(this).countMinesAdjacent() == 0) { - $(this).getAdjacentTiles().filter(':not(.revealed)').mousedown(); + $(this).getAdjacentTiles().filter(':not(.revealed)').mouseup(); } } @@ -529,7 +529,7 @@ //number of flags matches number of adjacent mines if (parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { - $(this).mousedown(); + $(this).mouseup(); }); } } @@ -541,17 +541,41 @@ } else { $(this).toggleClass("flagged"); } + + clearTimeout(timeout); } $(document).on("contextmenu", "li", function(event) { event.preventDefault(); }); + $(document).on("mousedown", "li", function(event) { + var x = $(this).getX(); + var y = $(this).getY(); + + timeout = setTimeout(function() { + $('ul:eq(' + y + ') li:eq(' + x + ')').rightClick(); + mouseHeld = true; + }, clickholdMs); + }); + + $(document).on("mouseleave", "li", function(event) { + clearTimeout(timeout); + }); + + $(document).on("mouseup", "li", function(event) { event.preventDefault(); + clearTimeout(timeout); + if (!inputEnabled) return; + if (mouseHeld) { + mouseHeld = false; + return; + } + switch (event.which) { case 3: $(this).rightClick(); From c75ff197f8b33cd02e7b7948aa2b9472a809f158 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 10:52:29 +0000 Subject: [PATCH 04/12] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index ad09561..17667ba 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Rows with exploded mines cannot be cleared. See how far you can get! Left-click to clear a tile. Right-click to flag a mine. Middle-click a number to clear any non-flagged adjacent tiles. ## stuff to add -add support for mobile devices/1-button mice (probably hold down to flag a mine) - save game using html5 local storage so player can come back later make cleared columns slide left? From d379c5e10497bae204ad463629dadc7ccffbd1bf Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 11:15:32 +0000 Subject: [PATCH 05/12] ipad support - hopefully --- index.html | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index c961122..914253c 100644 --- a/index.html +++ b/index.html @@ -260,7 +260,7 @@ } window.removeClearedRows = function() { - var rowsToRemove = $('#game ul').filter(function() { + var rowsToRemove = $('#game ul:not(.removing)').filter(function() { return $(this).checkRow(); }); @@ -268,6 +268,8 @@ if (rowsToRemove.length == 0) return; + rowsToRemove.addClass("removing"); + rowsToRemove.each(function() { score += $(this).children('.mine').length; @@ -371,10 +373,6 @@ return $(this).parent('ul').index(); } - $.fn.getGameboardPos = function() { - return gameBoard[$(this).getY()][$(this).getX()]; - } - $.fn.isMine = function() { return $(this).hasClass("mine"); } @@ -550,7 +548,7 @@ }); - $(document).on("mousedown", "li", function(event) { + $(document).on("mousedown touchstart", "li", function(event) { var x = $(this).getX(); var y = $(this).getY(); @@ -564,7 +562,7 @@ clearTimeout(timeout); }); - $(document).on("mouseup", "li", function(event) { + $(document).on("mouseup touchend", "li", function(event) { event.preventDefault(); clearTimeout(timeout); From 881d4acbc389166fdf3ceb8e08b09c249764e947 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 11:30:19 +0000 Subject: [PATCH 06/12] Prevent text selection --- index.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 914253c..82a8111 100644 --- a/index.html +++ b/index.html @@ -16,6 +16,7 @@ width: 100vw; overflow: hidden; font-family: Helsinki; + -webkit-user-select: none; } body { @@ -266,7 +267,7 @@ var numRowsToRemove = rowsToRemove.length; - if (rowsToRemove.length == 0) return; + if (numRowsToRemove == 0) return; rowsToRemove.addClass("removing"); From 0fda6f974c4f2f3e16df048fd19edb1f5bec929e Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 11:38:10 +0000 Subject: [PATCH 07/12] Remove hacky hack --- index.html | 6 ------ 1 file changed, 6 deletions(-) diff --git a/index.html b/index.html index 82a8111..a280da4 100644 --- a/index.html +++ b/index.html @@ -319,13 +319,7 @@ //click blank tiles $('li.revealed:not(.mine):empty').mouseup(); - - //this is a bit of a hack :( oh well - $('ul:gt(' + gameBoardHeight + ')').remove(); }); - - //this is a bit of a hack :( oh well - $('ul:gt(' + gameBoardHeight + ')').remove(); inputEnabled = true; } From 31d45fcb56bf13c65238e06d4a20b9d3c9d03b5b Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 11:44:37 +0000 Subject: [PATCH 08/12] Update README.md --- README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 17667ba..5ef4949 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,4 @@ Need to test on mobile devices etc. ## bugs the player can cheat under certain conditions; if there is only one tile left on a row, the player can flag it and if it is a mine, the row will clear. if not, the player can unflag it and click it. not sure how big a deal this is really. -the game adds too many rows and then deletes the extra rows, instead of just adding the correct number of rows in the first place. this is due to the row clearing method nesting and adding the new rows several times as a result - -the scoring system is wrong due to the above problem; if any tiles cascade during removal of rows, the score is added again for each step of the cascade leading to vastly inflated scores - -game is apparently broken in Safari (not sure which version) +game is apparently broken in Safari (not sure which version) and iPhone From a510ea01add39cd53601503f1c2b6a5bcf3b7d69 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 11:48:06 +0000 Subject: [PATCH 09/12] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5ef4949..9887ce1 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,5 @@ Need to test on mobile devices etc. the player can cheat under certain conditions; if there is only one tile left on a row, the player can flag it and if it is a mine, the row will clear. if not, the player can unflag it and click it. not sure how big a deal this is really. game is apparently broken in Safari (not sure which version) and iPhone + +colours used are not safe for red-green colourblindness From 6fddbbf5d2fdf1d3cb9a714a1a0320a576a59a02 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Sat, 7 Mar 2015 11:54:23 +0000 Subject: [PATCH 10/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9887ce1..a29911b 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,6 @@ Need to test on mobile devices etc. ## bugs the player can cheat under certain conditions; if there is only one tile left on a row, the player can flag it and if it is a mine, the row will clear. if not, the player can unflag it and click it. not sure how big a deal this is really. -game is apparently broken in Safari (not sure which version) and iPhone +need a fallback for browsers that don't support CSS3 viewport sizing colours used are not safe for red-green colourblindness From 76aa1592d8ce83f57a6d5827f48404d23342d39d Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Sun, 8 Mar 2015 21:48:03 +0000 Subject: [PATCH 11/12] Various changes Added help text Removed unused variables Refactored "add new mine" functionality Added funcionality for removing cleared columns (disabled for now) --- index.html | 172 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 118 insertions(+), 54 deletions(-) diff --git a/index.html b/index.html index a280da4..125e72c 100644 --- a/index.html +++ b/index.html @@ -66,8 +66,8 @@ } #setup h1 { - margin-top: 8vmin; - margin-bottom: 8vmin; + margin-top: 6vmin; + margin-bottom: 6vmin; } #setup h2 { @@ -109,7 +109,7 @@ position: absolute; left: 38vmin; - top: 59vmin; + top: 75vmin; background: #768087; background: -moz-linear-gradient(top, #768087 0%, #53595e 100%); @@ -207,17 +207,25 @@ li.mines8 { color: #8c4600; } + + p { + color: #fff; + font-size: 4.3vmin; + padding: 0 10vmin; + } + + strong { + color: #fe7ac6; + } +