A fully functional clone of the classic Windows Minesweeper with precise mechanics, a high-score table, three difficulty levels and MVC architecture.
-
Exact original behavior
- Left-click to reveal a cell, right-click to place/remove a flag.
- First click never hits a mine – mines are placed after the first move.
- Flags can be placed even before the first click.
- Automatic flood-fill for empty areas.
-
Advanced mechanics
- Mouse wheel click on an open number – reveals all neighbours if the correct number of flags is placed around it.
- Dynamic mine counter:
remaining mines = total mines - flags placed.
-
Graphics & UI
- Custom images for mines, flags, numbers, and cells (loaded via Swing).
- Responsive layout using
GridLayoutfor the game board andGridBagLayoutfor the control panel.
-
Persistence & records
- Stopwatch starts after the first click on the board.
- High-score table saved between sessions (serialized to
records.json). - Menu with: New Game, High Scores, Settings, About, Exit.
-
Three standard difficulty levels
- Beginner: 9×9, 10 mines
- Intermediate: 16×16, 40 mines
- Expert: 16×30, 90 mines
- Java 21+ (Core)
- Swing (javax.swing) – GUI framework
- MVC (Model-View-Controller) – separates logic, presentation and control
- Serialization – for saving high scores
The project strictly follows the Model-View-Controller pattern:
-
Model (
GameModel)- Stores the board state: mine locations, flags, revealed cells.
- Contains pure business logic: reveal cell, check win/loss, place mines after first click.
- No UI dependency.
-
View (
GameView)- Renders the game board, mine counter, and timer.
- Uses
JButtonfor each cell. - Delegates user input to the Controller.
-
Controller (
GameController)- Handles mouse events (left, right, wheel).
- Updates Model and refreshes View.
- Manages timer, menu actions and high-score logic.
git clone https://github.com/Juanoff/minesweeper.git
cd minesweeperFile → Open → select the project folder.
Wait for the project to load (no external dependencies).
The easiest way to run the game is directly from your IDE: locate the Application class and run it.
Alternatively, run via Gradle:
./gradlew run

