Skip to content

About

๐ŸŽฉ 2048 game is cloned with ReactJS, CSS3.

Topics

Resources

Stars

10 stars

Watchers

1 watching

Forks

Latest commit

ย 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

2048 in React: Modern Sliding Tile Puzzle & Audio Engine

React Web Audio API CSS3 License: MIT

A polished, market-ready React implementation of the classic 2048 sliding tile puzzle featuring real-time score tracking, persistent high scores, multi-step undo history, Web Audio sound effects, and celebratory confetti effects.


โœจ Features & Market-Ready Polish

  • ๐ŸŽต Native Web Audio API Sound Synthesizer:
    • Zero external MP3/WAV file dependencies; 100% offline, zero latency, and crystal clear.
    • Directional sliding swoosh, dynamic harmonic merge chimes that scale in pitch as tile numbers rise, triumphant victory arpeggio, soft game-over melody, and crisp button clicks.
    • Sound toggle with persistent preference memory in localStorage.
  • ๐Ÿ† Comprehensive Score Management System:
    • Live Score accumulation when tiles merge.
    • Floating animated points badge (+4, +8, +16...) that pops up above the score box on every combination.
    • All-time Best Score tracking persisted in browser localStorage.
    • Move Counter tracking efficiency.
  • โ†ฉ๏ธ Full Multi-Step Undo Engine:
    • Snapshot state history stack allowing players to revert their last moves anytime.
  • ๐ŸŽ‰ Canvas Confetti Celebration:
    • Dynamic 60 FPS HTML5 Canvas confetti particle explosion upon reaching the 2048 tile!
    • "Keep Going" mode allowing players to continue playing for 4096, 8192, and beyond.
  • ๐Ÿ“ฑ Dual Input Controls (Keyboard, Swipe, & Virtual D-Pad):
    • Desktop keyboard support: Arrow keys and W A S D.
    • Mobile touch swipe gesture detection.
    • On-screen virtual directional D-pad for touchscreens and accessibility.
  • โšก Optimized CSS3 Hardware Acceleration:
    • Orthogonal movement matrix ($2 \times 4^2$ animations rather than $4^4$) keeping animation CSS under 3 KB.
    • Elastic pop on new tile spawn and 1.2x scale pulse on merged tiles.
    • Frosted glassmorphism modal overlays for Victory and Game Over states.
    • Responsive viewport scaling for seamless gameplay across mobile, tablet, and desktop screens.

๐ŸŽฎ How to Play

  1. Move Tiles: Use Arrow keys, W A S D, swipe on mobile, or click the on-screen D-pad.
  2. Merge Numbers: When two identical tiles collide, they combine into one with their sum ($2 + 2 = 4$, $4 + 4 = 8$, ..., $1024 + 1024 = 2048$).
  3. Reach 2048: Build the 2048 tile to win, or choose Keep Going to chase higher scores!

๐Ÿš€ Quickstart Guide

1. Clone the Repository

git clone https://github.com/aeskafi/2048-react.git
cd 2048-react

2. Install Dependencies

npm install

3. Start Development Server

npm start

Open http://localhost:3000 in your browser to start playing immediately.


๐Ÿ—๏ธ Production Build & Deployment

npm run build

Production-ready static bundles will be compiled to build/, ready for zero-config deployment on Vercel, Netlify, or GitHub Pages.


๐Ÿ“ Project Architecture

โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ favicon.ico
โ”‚   โ””โ”€โ”€ index.html           # HTML5 shell (#boardDiv root, viewport & metadata)
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ cell.jsx         # Background grid cell
โ”‚   โ”‚   โ”œโ”€โ”€ endGame.jsx      # Glassmorphic Victory / Game Over modal with stats & actions
โ”‚   โ”‚   โ”œโ”€โ”€ mainBoard.jsx    # Core game loop, matrix rotation, score management, & undo
โ”‚   โ”‚   โ””โ”€โ”€ tileView.jsx     # Dynamic positioning, merge pop, & font scaling
โ”‚   โ”œโ”€โ”€ styles/
โ”‚   โ”‚   โ””โ”€โ”€ styles.css       # Orthogonal animations, tile color palette, & responsive rules
โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”œโ”€โ”€ confetti.js      # Pure HTML5 Canvas confetti explosion system
โ”‚   โ”‚   โ””โ”€โ”€ sound.js         # Web Audio API procedural sound synthesizer
โ”‚   โ””โ”€โ”€ index.js             # React DOM mounting entrypoint
โ”œโ”€โ”€ package.json
โ””โ”€โ”€ LICENSE                  # MIT License

๐Ÿ‘ค Author & Mission

Crafted and curated with precision by Arham Eskafi (arham.dev) โ€” Rapid MVP Specialist, Full-Stack Architect, and Tech Nomad.

Follow the overland journey of building software while living on the open road at Walk Cook Live.


๐Ÿ“„ License

This repository is licensed under the MIT License.

About

๐ŸŽฉ 2048 game is cloned with ReactJS, CSS3.

Topics

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages