A simple educational Mine Sweeper game built with HTML, CSS, and Vanilla JavaScript.
This project was built as a learning exercise to practice:
- DOM manipulation
- Event handling
- Game logic in JavaScript
- You start each game with 3 lives (hearts).
- Select a difficulty level before starting the game:
- Beginner: Smaller board with fewer mines.
- Medium: Standard board and mine count.
- Expert: Larger board with many mines.
- Left-click on a cell to reveal it:
- If you click on a mine, you lose one life.
- The game continues until all lives are lost or all non-mine cells are revealed.
- Right-click on a cell to place or remove a flag.
- Numbers on cells show how many mines are adjacent to that cell.
- Timer and mine counter help track your progress.
💡 Note: Unlike classic Minesweeper, this version allows up to 3 mistakes before the game is over!
- 🎛️ Difficulty Levels: Beginner, Medium, Expert.
- ❤️ Lives System: 3 hearts per game — survive up to 3 mistakes.
- 🕒 Timer: Tracks how long each game takes.
- 💾 Best Score Tracking: Saves your best times per difficulty level.
- 💡 Hints: Reveal neighboring cells temporarily.
- 🛡️ Safe Click: Highlights a safe cell to help you progress.
- 🔍 Mega Hint: Temporarily reveals a larger area of the board.
- 🌙 Dark Mode: Toggle between light and dark themes.
-
Board Initialization:
- The board is generated as a 2D array.
- Mines are randomly placed after the first click to avoid immediate loss.
- The number of mines depends on the selected difficulty.
-
Revealing Cells:
- Clicking a cell triggers a recursive reveal if there are no adjacent mines.
- If a cell has mines nearby, it shows a number.
-
Flagging:
- Right-click toggles a flag on a cell to mark suspected mines.
-
Winning Condition:
- The player wins when all non-mine cells are revealed.
-
Losing Condition:
- The player loses after revealing mines and losing all 3 lives.
You can try the project live here:
👉 Mine-Sweeper Live
- Clone or download the repository:
git clone https://github.com/OrAntebi/Mine-Sweeper.git
Here’s what the game looks like while playing: