diff --git a/TODO.md b/TODO.md index 4cd187f..af952f6 100644 --- a/TODO.md +++ b/TODO.md @@ -1,4 +1,24 @@ +* Add leaderboard +* Add tutorial (a few lines and images of coffins, tombstones, etc) +* Different input scheme, because on iPhones long-pressing always + selects text (or is there a --safari-user-select?) +* Sync data between devices (maybe it's possible with some Webxdc + functions) * Saving the game data to a file, so high scores, unlocked levels etc. can be shared across updates. Or, someone unfair can cheat. * Randomly rotate, tint, etc., cells to add variety * Refractor the code +* Record new sounds, add sound variations. Required sounds: + * Breaking wood, at least 3 sounds + * Digging dirt, at least 3 sounds + * A "muahaha" sound on discovering a vampire + * Bat sounds for bats flying out of coffins + * (Maybe) a sound of marble, like the one when you open up a tomb +* Revamp the graphics, add more consistency. New spirtes required: + * Wood chips (when removing the lid off coffin) + * Bats (preferably animated with two frames to simulate flying) + * Some better, less copyright-infringing background (though this one + is heavily modified already) + * Main menu icon + * Restart icon +* Analyze the UI, think about potential improvements diff --git a/game.js b/game.js index c3f85e7..b8810b6 100644 --- a/game.js +++ b/game.js @@ -39,10 +39,9 @@ function restart_game() { initial_mines_count = 10 + current_level; stop_timing(); seconds_elapsed = 0; + document.body.classList.remove("main-menu", "popup-victory", "popup-failure"); + document.body.classList.add ("game-view"); $("#time").innerText = get_seconds_readable(seconds_elapsed); - $("#finished-popup").style = "display:none;"; - $("#restart").style = "display:block"; - $("#newgame").style = "display:block"; } function start_or_continue_game(level) { @@ -176,8 +175,13 @@ function count_neighbouring_mines(cell) { function reveal_mines(cell) { let n_mines = count_neighbouring_mines(cell); - cell.classList.remove("unknown"); - cell.classList.add("known"); + + if (cell.classList.contains("unknown")) { + reveal_cell_cosmetic(cell); + cell.classList.remove("unknown"); + cell.classList.add("known"); + } + if (n_mines == 0) { get_neighbours(cell).forEach(function(c) { if (c.classList.contains("unknown")) { @@ -187,13 +191,10 @@ function reveal_mines(cell) { c.classList.remove("flagged"); } }); - } - if (n_mines > 0 && !cell.classList.contains("mine")) { + } else if (n_mines > 0 && !cell.classList.contains("mine")) { cell.innerText = "" + n_mines; cell.classList.add("n" + n_mines); } - - reveal_cell_cosmetic(cell); } function reveal_cell_cosmetic(cell) { @@ -210,15 +211,13 @@ function reveal_cell_cosmetic(cell) { // Shows the game won/over popup. function show_popup(victory) { - $("#finished-popup").style = "display:flex;"; - $("#restart").style = "display:none"; - $("#newgame").style = "display:none"; - if (!victory) { - $("#nextlevel").style = "display:none"; - $("#message").innerText = "You've lost!" - } else { - $("#nextlevel").style = "display:block"; + document.body.classList.remove("popup-victory", "popup-failure"); + if (victory) { + document.body.classList.add("popup-victory"); $("#message").innerText = "You've won!" + } else { + document.body.classList.add("popup-failure"); + $("#message").innerText = "You've lost!" } } @@ -257,8 +256,6 @@ function lose_game() { stop_timing(); show_popup(false); $$("#minefield div").forEach(function(cell) { - cell.classList.remove("unknown"); - cell.classList.add("known"); reveal_mines(cell); if (cell.classList.contains("exploded")) { cell.innerText = ""; diff --git a/index.html b/index.html index f4e8156..52cdb84 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - + -