A browser-based Minesweeper game implementation built with vanilla JavaScript.
This is a sandbox project for exploring GitHub Copilot features while building a classic Minesweeper game. The game features a clean, modern interface and supports multiple difficulty levels.
- Classic Minesweeper gameplay
- Left-click to reveal cells
- Right-click to place/remove flags
- Auto-reveal adjacent cells when clicking on empty cells
- Win/lose detection
- Visual feedback with emojis and colors
- Player Listeners: Add custom JavaScript code that responds to game events
- Create, update, and delete listeners through the UI
- Real-time code validation with helpful error messages
- Color-coded feedback (green for success, red for errors)
minesweeper/
├── index.html # Main HTML file with game layout and structure
├── style.css # Game styling and visual design
├── minesweeper.js # Game logic and interaction handling
├── README.md # Project documentation (this file)
└── CONTRIBUTING.md # Guidelines for contributors
Simply open index.html in a web browser. No build process or dependencies required!
# Using Python 3
python -m http.server 8000
# Using Node.js (if you have http-server installed)
npx http-server
# Or just open the file directly
open index.html # macOS
start index.html # WindowsThen navigate to http://localhost:8000 in your browser.
- Reveal cells: Left-click on a cell to reveal it
- Place flags: Right-click on a cell to mark it as a mine
- Win: Reveal all non-mine cells
- Lose: Click on a mine
- Numbers indicate how many mines are adjacent to that cell (including diagonals)
- Empty cells (0 adjacent mines) automatically reveal their neighbors
- You can flag cells you think contain mines
- The game ends when you either:
- Reveal all non-mine cells (WIN)
- Click on a mine (LOSE)
The project follows a modular structure:
The main game logic is organized into clear sections:
-
Minesweeper Class: Core game logic
- Board initialization and mine placement
- Cell rendering and visual updates
- User interaction handlers
- Game state management
-
Global Functions: Game control functions
startNewGame(): Initializes a new game instance
-
Event Listeners: User interaction setup
- Page load initialization
- Button click handlers
For detailed code organization and contribution guidelines, see CONTRIBUTING.md.
If you're contributing to this project, especially when multiple PRs are active, please read CONTRIBUTING.md for:
- Code organization guidelines
- Merge conflict resolution strategies
- Best practices for concurrent development
- Section markers for easy navigation
The project is actively being enhanced with:
- Game configuration options (difficulty levels)
- API for building assistants
- Advanced gameplay features (flag-based cell opening)
- Better documentation for agents and humans
This game works in all modern browsers that support:
- ES6 JavaScript (classes, arrow functions, template literals)
- CSS Grid
- DOM Event listeners
Tested on recent versions of:
- Chrome
- Firefox
- Safari
- Edge
This project is for educational and demonstration purposes.
Built as a sandbox for exploring GitHub Copilot capabilities.