zminic /
minesweeper.js
Minesweeper game implementation in HTML, CSS and Javascript
32/100 healthLoading repository data…
propjockey / repository
MineSweeper implemented in CSS + HTML using the Space Toggle trick (no JavaScript!)
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
MineSweeper implemented in CSS + HTML using the Space Toggle trick (no JavaScript!)
PLAY IT HERE!
NOTE: this is another stress test, expect lag for the next several years of average computer advancement!
Since it's not practical to clear all the spaces when you expose an empty area (without loops or causing cyclic references), the win condition has been reduced to:
This also allows you to win when it comes down to a forced-guess since you can flag without consequence. If you pick right and haven't flagged any non-bombs, you win.
The fields are only defined by where the bombs are (and that those spaces are not not-bombs).
The rest of the game, counter, numbers, etc flow from there, so the bombs can be placed anywhere, and in any number.
This is the (lazy/inefficient) script I ran before hand to generate the 16 included Fields:
var levels = [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]
var genlvl = (lvl) => {
var y = ~~(Math.random() * 16)
var x = ~~(Math.random() * 30)
var key = `bomb-${y}-${x}`
lvl[key] = `--${key}: ; --not-${key}: initial;`
}
levels.forEach(lvl => {
while (Object.keys(lvl).length < 99) { genlvl(lvl) }
})
var cssoutput = ""
levels.forEach((lvl, i) => {
var out = ` #level-${ i.toString(10).padStart(2, "0") }:checked ~ #ram {
--level: "${ (i + 1).toString(10).padStart(2, "0") }";
${Object.values(lvl).join("\n ")}
}
`
cssoutput += out
})
// cssoutput is the only css necessary to create new fields
--toggler: ;, then it can be added to anything (any number of times) without changing the value
--toggler: ;
--red-if-toggler: var(--toggler) red;
background: var(--red-if-toggler, green); /* will be red! */
initial --toggler: initial; (or was never defined), then it can be added to anything to force-fallback when referenced
--toggler: initial;
--red-if-toggler: var(--toggler) red;
background: var(--red-if-toggler, green); /* will be green! */
--red-if-togglersalltrue: var(--tog1) var(--tog2) var(--tog3) red;
--red-if-anytogglertrue: var(--tog1, var(--tog2, var(--tog3))) red;
#common-css-var-area { /* default any "not" values to truthy */ --not-flagged: ; }
#mycheckbox:checked ~ #common-css-var-area { --flagged: ; --not-flagged: initial; }
#anotherbox:checked ~ #common-css-var-area { --open: ; }
#common-css-var-area {
--yellow-if-flagged-and-open: var(--open) var(--flagged) yellow;
--white-if-not-flagged-and-open: var(--open) var(--not-flagged) white;
--red-if-flagged: var(--flagged) red;
color: var(--yellow-if-flagged-and-open, var(--white-if-not-flagged-and-open, var(--red-if-flagged, black)))
}
/* color will be black if not flagged and not open */
--pnl: /**/; and calls it prop-and-lockFollow me on Twitter for more web dev insanity! (and feel free to ask questions!)
Selected from shared topics, language and repository description—not editorial ratings.
zminic /
Minesweeper game implementation in HTML, CSS and Javascript
32/100 healthBrandonDusseau /
Classic Minesweeper look and feel implemented in HTML and Javascript
53/100 healthJithu-SM /
A simple and visually appealing browser-based implementation of Minesweeper, featuring animations, timer functionality, and win/loss messaging. Built with HTML, CSS, and JavaScript, this project is great for learning grid-based game design and basic interactivity in web development.
/100 healthlyamamot /
Minesweeper, implemented in in HTML/JS.
28/100 healthnethe550 /
A minesweeper implementation in HTML / CSS / JS
37/100 healthdrewish /
An implementation in HTML/JS I did for a coding challenge.
27/100 health