← Back to ratslair.com
aboutsummaryrefslogtreecommitdiff

Mine Sweeper

A Minesweeper clone in C and SDL2, and the project where recursive flood-fill finally clicked for me.

A 10x10 board gets seeded with 15 mines, each tile counts the mines in its own 3x3 neighborhood, and clicking an empty tile (zero neighboring mines) sets off a small recursive reveal that keeps opening neighbors until it runs into a ring of numbered tiles on every side. Watching that cascade unfold correctly for the first time, opening up a whole empty region from a single click, was the fun part of this one.

There's also a chording shortcut that reveals every unflagged tile around the one you're hovering, for clearing a region in one go once you've flagged its mines.

Controls

  • Left click: reveal a tile
  • Right click: flag/unflag a tile
  • Space: chord (reveal all unflagged neighbors of the hovered tile)

Building

Needs SDL2 and SDL2_ttf.

make
./mine_sweeper

License

GPLv3, see LICENSE.