egui-minesweeper
A self-contained Minesweeper game library for egui.
Features
- Pure game logic struct (
MinesweeperGame) with no egui dependency — usable headlessly or with any renderer - Ready-to-use egui
Widget(MinesweeperWidget) that renders a fully interactive board - Safe first click: mines are placed on the first reveal, guaranteeing the player can never lose immediately
- Iterative flood-fill reveal (no recursion, safe on large boards)
- Classic Minesweeper cell styling: raised hidden cells, numbered revealed cells, flagging, mine reveal on loss
Usage
Add the dependency:
[]
= "0.1"
Then use it in your egui app:
use ;
// Store the game in your app state
let mut game = new;
// Inside your egui update/UI closure:
ui.add;
// Optionally set a fixed cell size (otherwise fills available space):
ui.add;
After each frame you can inspect game.status to check for a win or loss:
use GameStatus;
match game.status
To start a new game with the same settings:
game.reset;
egui version compatibility
| egui-minesweeper | egui |
|---|---|
| 0.1 | 0.34 |
License
Licensed under either of MIT or Apache-2.0 at your option.