ClojureScript minesweeper game with p5.js
Here's a simple minesweeper game implemented with ClojureScript, p5.js and shadow-cljs. The code is in my demo collection on GitHub.
Click on a cell to reval it. If it's a bomb, you lose. You win by revealing all cells that are not bombs. To start a new game just click anywhere on the grid. (There's no flag-support)
Unfortunately, I think the flood-reveal code is a tiny bit wrong because it doesn't reveal the outermost diagonal cells.
The game lacks several features that are common to minesweeper games, like the ability to add flags and chose difficulty level. I actually found another ClojureScript + p5.js minesweeper at https://sneakycode.net/minesweeper that has all those things, I recommend you take a look.
Two technical things that are bugging me: how to handle game state and configuration settings in a way that's clean and scalable.
p5.js uses global callbacks, and I felt I had to use global variables (atoms) so that the callbacks could find them. Maybe a cleaner solution is to use a single global state variable that the non-callback functions could deconstruct.
I "stored" the configuration settings in a function called
returns a map with all the settings. It's a mess. If I were to use a
single global state variable it might make sense to store the settings