Bombsweeper

Just a rudimentary clone of a classic puzzle game, made as a learning project for Godot 4.

Features variable board size and number of bombs.

Design:

https://github.com/codybrock/bombsweeper

The cells are extended button nodes. I thought about using a classic multi-dimensional array with -1 for mines and positive numbers for the neighbor counts, but I decided to lean into Godot's capabilities in order to get more comfortable with its unique paradigm.

I used a GridContainer node to arrange the cells, and extended it with a multi-dimensional array to reference cells by coordinate. States are managed with a simple enum.

Clicking on cells fires off an event so that a higher level node can deal with things like checking neighbors, that way individual cells don't have to go looking for their siblings, which would bring a bunch of ugly coupling into the design.

Map generation occurs after the player clicks their first cell, that way they don't click a mine right off the bat. The maps aren't perfect, since Minesweeper has exponential complexity. You can't deterministically generate solvable maps in a reasonable amount of time. I might go back and implement a simple AI that tests solvability and times out if a map gets too complex.

It would be nice to go back and add a timer and a little nicer UX in general.


Leave a comment

Log in with itch.io to leave a comment.