Welcome to the Minesweeper Game! ๐ This is a classic Minesweeper game built with JavaScript, where you can test your puzzle-solving skills and try not to explode! ๐ฃ
The game board is a grid of cells, each of which may hide a mine (๐ฃ), a flag (๐ฉ), or a number (๐ข). The goal is to uncover all the cells without mines. Hereโs how weโve set it all up:
-
Cells Creation: We created a parent
<div>
and inserted lots of child<div>
s representing the cells. Each cell contains:- A mine element (๐ฃ)
- A flag element (๐ฉ)
- A number element (๐ข)
-
Visibility: These elements show or hide depending on the map details, revealing what's underneath the cell when clicked.
-
Size: The number of cells is based on the selected size:
- Extra Small: 9x16 grid
- Small: 16x16 grid
- Medium: 32x16 grid
- Large: 48x64 grid (not applicable yet because of performance issues)
- Extra Large: 100x100 grid (not applicable yet because of performance issues)
-
Difficulty: The density of mines per size depends on the difficulty level:
- Easy: 10% of cells contain mines ๐
- Medium: 20% of cells contain mines ๐ช
- Hard: 40% of cells contain mines ๐ฑ
- Impossible: 60% of cells contain mines ๐ฅ
Weโve implemented the Flood Fill Algorithm to determine which squares to uncover when a square is clicked. Hereโs how it works:
- Initial Click: When you click on a cell, if it has no neighboring mines (number = 0), the algorithm will start uncovering all adjacent cells recursively until it reaches cells with numbers.
- Recursive Uncovering: This ensures that large empty areas are uncovered quickly and efficiently, making the game smoother and more exciting!
- Flag Mode: Toggle between uncovering cells and placing flags with a simple click! This helps you mark potential mines and avoid explosions.
- Timer: A ticking clock to keep you on your toes! โฑ๏ธ We used the TickWatch library by HichemTab-tech to implement the timer.
Weโre always open to contributions and suggestions! If you have any ideas to improve the game or if you want to contribute to the project, feel free to reach out or create a pull request. Let's make this game even more fun together! ๐
We hope you have a blast playing our Minesweeper game! It's designed to be challenging and fun. So, go ahead and see if you can uncover all the cells without hitting a mine. Good luck, and happy sweeping! ๐งน๐ฃ
Created with โค๏ธ by HichemTab-tech.