I wrote this simple Minesweeper game when offering the challenge to a friend who was trying to get back into programming. It turned out to be a fun little project so I figured I’d share the code here for those who are interested.

The game itself is made up of a board which contains cells/points. According to the game rules, cells (which may or may not contain mines) may be clicked or flagged. The objective is to flag all the cells containing mines and to click all of the “safe” cells. Once all of the safe cells are checked and all of the cells with mines are flagged, the game is won. If a cell with a mine is clicked, the game is lost.
I kept the game engine (msw.game.Engine) separate from the GUI, so the engine itself can be reused and plugged into any GUI aside from the one I included in the project. The main class is msw.game.Main. If you find any bugs or see any room for improvement, please feel free to share. (One feature I didn’t yet add was a timer and proper handling when the game finishes [e.g. high scores]).

2 Comments
The GUI version is much nicer than where I left mine at.. lol
You should finish it.. or extend my game by completing the timer and game over / high scores…
One Trackback
[...] Contact « Minewsweeper [...]