Skip to content

Sugar-Coffee/minesweeper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ฃ Minesweeper Game

Minesweeper Game Header

A beautiful, modern take on the classic Minesweeper puzzle game


๐Ÿš€ Live Demo

Next.js 15 TypeScript Tailwind CSS Framer Motion


โœจ Features

๐ŸŽฏ Classic Gameplay - Traditional minesweeper rules with modern UX
๐ŸŒ™ Dark/Light Mode - Beautiful themes that adapt to your preference
๐Ÿ“ฑ Mobile Optimized - Responsive design that works perfectly on all devices
๐Ÿ’พ Save/Resume - Automatic game state persistence using localStorage
๐ŸŽจ Smooth Animations - Framer Motion powered transitions and effects
๐Ÿ”ฅ Modern Tech Stack - Built with Next.js 15, TypeScript, and Tailwind CSS
๐Ÿ“Š Google Analytics - Comprehensive event tracking for insights
๐Ÿš€ PWA Ready - Installable as a Progressive Web App
โ™ฟ Accessible - WCAG compliant with keyboard navigation support

๐ŸŽฎ How to Play

  1. Left Click - Reveal a cell
  2. Right Click - Flag/unflag a suspected mine
  3. Middle Click - Chord click (reveal all adjacent cells when flags match mine count)
  4. Goal - Reveal all non-mine cells without hitting a mine

Game Rules

  • Numbers indicate how many mines are adjacent to that cell
  • Use logic and deduction to identify mine locations
  • Flag suspected mines to help track your progress
  • Game is won when all non-mine cells are revealed

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18.0 or later
  • npm, yarn, pnpm, or bun

Installation

# Clone the repository
git clone https://github.com/yourusername/minesweeper.git
cd minesweeper

# Install dependencies
npm install

# Start the development server
npm run dev

Open http://localhost:3000 to play the game locally.

๐Ÿ› ๏ธ Available Scripts

Script Description
npm run dev Start development server with hot reload
npm run build Build the app for production
npm run start Start the production server
npm run lint Run ESLint for code quality checks

๐Ÿ—๏ธ Tech Stack

Frontend

Analytics & SEO

  • @next/third-parties - Google Analytics integration
  • Comprehensive metadata - Open Graph, Twitter Cards, structured data
  • SEO optimized - Sitemap, robots.txt, canonical URLs

Development

  • ESLint - Code linting and quality
  • PostCSS - CSS processing
  • Git - Version control

๐Ÿ“ Project Structure

minesweeper/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ app/                    # Next.js app directory
โ”‚   โ”‚   โ”œโ”€โ”€ layout.tsx         # Root layout with metadata
โ”‚   โ”‚   โ”œโ”€โ”€ page.tsx           # Home page
โ”‚   โ”‚   โ”œโ”€โ”€ globals.css        # Global styles
โ”‚   โ”‚   โ””โ”€โ”€ sitemap.ts         # Dynamic sitemap generation
โ”‚   โ”œโ”€โ”€ components/            # React components
โ”‚   โ”‚   โ”œโ”€โ”€ GameBoard.tsx      # Main game board grid
โ”‚   โ”‚   โ”œโ”€โ”€ GameCell.tsx       # Individual cell component
โ”‚   โ”‚   โ”œโ”€โ”€ GameControls.tsx   # Game controls and stats
โ”‚   โ”‚   โ”œโ”€โ”€ GameHeader.tsx     # Header component
โ”‚   โ”‚   โ”œโ”€โ”€ GameModal.tsx      # Win/lose modal
โ”‚   โ”‚   โ”œโ”€โ”€ GameTitle.tsx      # Title and description
โ”‚   โ”‚   โ”œโ”€โ”€ MinesweeperGame.tsx # Main game logic wrapper
โ”‚   โ”‚   โ””โ”€โ”€ ThemeProvider.tsx  # Dark/light mode provider
โ”‚   โ””โ”€โ”€ lib/                   # Utility functions
โ”‚       โ”œโ”€โ”€ game-logic.ts      # Core game mechanics
โ”‚       โ””โ”€โ”€ utils.ts           # Helper utilities
โ”œโ”€โ”€ public/                    # Static assets
โ”‚   โ”œโ”€โ”€ icon.svg              # App icon
โ”‚   โ”œโ”€โ”€ apple-icon.svg        # Apple touch icon
โ”‚   โ”œโ”€โ”€ favicon.svg           # Favicon
โ”‚   โ”œโ”€โ”€ og-image.svg          # Open Graph image
โ”‚   โ”œโ”€โ”€ manifest.json         # PWA manifest
โ”‚   โ””โ”€โ”€ robots.txt            # SEO robots file
โ””โ”€โ”€ package.json              # Dependencies and scripts

๐ŸŽฏ Game Logic

Core Mechanics

  • Random mine generation using seeded algorithms for reproducible games
  • Flood fill algorithm for revealing connected empty cells
  • Chord clicking for advanced gameplay
  • Win condition detection based on revealed non-mine cells
  • Save/resume functionality with localStorage persistence

Key Components

  • initializeBoard() - Creates game board with mines
  • revealCell() - Handles cell revelation with flood fill
  • flagCell() - Toggles flag state on cells
  • checkWinCondition() - Determines if player has won

๐Ÿ“Š Analytics Events

The game tracks user engagement through Google Analytics:

  • Game Start - When first cell is clicked
  • Game Won/Lost - With completion time and stats
  • Game Reset - From different UI elements
  • Modal Interactions - Close and new game actions

๐ŸŽจ Theming

The game supports both light and dark themes with:

  • System preference detection - Automatically matches OS theme
  • Manual toggle - Theme switcher in game controls
  • Persistent preference - Remembers user choice
  • Smooth transitions - Animated theme changes

๐Ÿš€ Deployment

Vercel (Recommended)

# Build the project
npm run build

# Deploy to Vercel
npx vercel --prod

Custom Domain Setup

The app is configured for minesweeper.sugarandcoffee.co.uk:

  • Update metadataBase in src/app/layout.tsx for your domain
  • Modify robots.txt and sitemap.ts with your URLs
  • Configure DNS and SSL certificates

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Guidelines

  1. Code Style - Follow the existing TypeScript/React patterns
  2. Components - Keep components focused and reusable
  3. Testing - Ensure game logic works correctly
  4. Performance - Maintain smooth 60fps animations
  5. Accessibility - Support keyboard navigation and screen readers

๐Ÿ“ License

This project is open source and available under the MIT License.

๐Ÿ™ Acknowledgments

  • Classic Minesweeper - For the timeless game design
  • Next.js Team - For the amazing React framework
  • Tailwind CSS - For the utility-first CSS approach
  • Framer Motion - For smooth animations
  • Lucide - For beautiful icons

๐ŸŽฎ Play Now | ๐Ÿ› Report Bug | ๐Ÿ’ก Request Feature

Made with โค๏ธ and โ˜•

About

The classic minesweeper in a nice design package with modern features.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors