A classic Minesweeper game built with React.js, featuring the traditional Windows Minesweeper look and feel.
- Classic Gameplay: Traditional minesweeper rules with left-click to reveal and right-click to flag
- Mine Counter: Shows remaining mines (total mines minus flagged cells)
- Timer: Tracks elapsed time during gameplay
- Game States: Visual feedback for winning, losing, and playing states
- Auto-reveal: Automatically reveals adjacent cells when clicking on empty cells
- Responsive Design: Works on different screen sizes
- Classic Windows Style: Authentic retro Windows Minesweeper appearance
- Objective: Reveal all cells that don't contain mines
- Left Click: Reveal a cell
- Right Click: Flag/unflag a cell (prevents accidental clicks)
- Numbers: Show how many mines are adjacent to that cell
- First Click: Never contains a mine (game generates mines after first click)
- Win Condition: Reveal all non-mine cells
- Lose Condition: Click on a mine
- Board Size: 9x9 grid
- Mine Count: 10 mines
- Difficulty: Beginner level (can be easily modified in the code)
-
Clone the repository:
git clone https://github.com/Chimk5/minesweeper-react.git cd minesweeper-react
-
Install dependencies:
npm install
-
Start the development server:
npm start
-
Open your browser and navigate to
http://localhost:3000
In the project directory, you can run:
Runs the app in development mode. Open http://localhost:3000 to view it in your browser.
Launches the test runner in interactive watch mode.
Builds the app for production to the build
folder.
Note: this is a one-way operation. Once you eject, you can't go back!
src/
├── components/
│ ├── Minesweeper.js # Main game logic component
│ ├── Minesweeper.css # Game styling
│ ├── Board.js # Game board component
│ ├── Board.css # Board styling
│ ├── Cell.js # Individual cell component
│ └── Cell.css # Cell styling
├── App.js # Main app component
├── App.css # App styling
├── index.js # App entry point
└── index.css # Global styles
- React 18: Modern React with hooks
- CSS3: Classic Windows Minesweeper styling
- JavaScript ES6+: Modern JavaScript features
The game implements the following core features:
- Random Mine Placement: Mines are placed randomly after the first click
- Recursive Reveal: Empty cells automatically reveal adjacent cells
- Mine Detection: Numbers show adjacent mine counts
- Flag System: Right-click to flag potential mines
- Win/Loss Detection: Game state management
- Timer: Elapsed time tracking
You can easily modify the game settings in src/components/Minesweeper.js
:
// Game settings
const ROWS = 9; // Board height
const COLS = 9; // Board width
const MINES = 10; // Number of mines
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the classic Windows Minesweeper game
- Built with modern React practices and hooks
- Styled to match the nostalgic Windows 95/98 Minesweeper appearance