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.
- ๐ต 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.
- Orthogonal movement matrix (
- Move Tiles: Use Arrow keys, W A S D, swipe on mobile, or click the on-screen D-pad.
-
Merge Numbers: When two identical tiles collide, they combine into one with their sum (
$2 + 2 = 4$ ,$4 + 4 = 8$ , ...,$1024 + 1024 = 2048$ ). - Reach 2048: Build the 2048 tile to win, or choose Keep Going to chase higher scores!
git clone https://github.com/aeskafi/2048-react.git
cd 2048-reactnpm installnpm startOpen http://localhost:3000 in your browser to start playing immediately.
npm run buildProduction-ready static bundles will be compiled to build/, ready for zero-config deployment on Vercel, Netlify, or GitHub Pages.
โโโ 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
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.
This repository is licensed under the MIT License.