A modern implementation of the classic 2048 puzzle game built with React. Combine tiles with the same number to reach the 2048 tile and achieve the highest score possible!
- 🎮 Classic 2048 Gameplay - Slide tiles in four directions to merge and create the 2048 tile
- 📊 Real-time Score Tracking - Keep track of your current and best scores
- ⌨️ Keyboard Controls - Use arrow keys to move tiles
- 📱 Responsive Design - Works seamlessly on desktop and mobile devices
- ♻️ Restart Game - Reset the board and start a new game at any time
- 💾 Local State Management - Game state is managed efficiently with React hooks
src/
├── components/
│ ├── Board.js # Main game board component
│ ├── Game.js # Game container and logic
│ ├── Score.js # Score display component
│ └── Tile.js # Individual tile component
├── hooks/
│ └── useKeyboard.js # Custom hook for keyboard input handling
├── utils/
│ └── gameLogic.js # Core 2048 game logic (movement, merging, scoring)
├── App.js # Main app component
├── App.css # Application styles
├── index.js # Entry point
└── index.css # Global styles
-
Clone the repository
git clone https://github.com/yourusername/react-2048-game.git cd react-2048-game -
Install dependencies
npm install
-
Start the development server
npm start
The app will open at http://localhost:3000
- Objective: Combine tiles with the same number to create larger numbers and reach the 2048 tile
- Controls:
- Use Arrow Keys (↑ ↓ ← →) to move tiles in any direction
- Tiles with the same number will merge when they slide into each other
- Each merge awards points equal to the new tile value
- Win Condition: Create a tile with the value 2048
- Game Over: The game ends when no more moves are possible
In the project directory, you can run:
Runs the app in development mode. Open http://localhost:3000 to view it in your browser. The page will reload when you make changes.
Launches the test runner in interactive watch mode.
Builds the app for production to the build folder. It correctly bundles React in production mode and optimizes the build for best performance.
- React (^19.2.3) - UI library
- React DOM (^19.2.3) - React rendering engine
- React Scripts (5.0.1) - Build and test scripts
- CSS3 - Styling
- Undo/Redo functionality
- Difficulty levels
- Dark/Light theme toggle
- Sound effects
- Animations for tile movements
- Leaderboard/High scores storage
- Mobile app version
Contributions are welcome! Feel free to fork the project and submit pull requests for any improvements.
This project is open source and available under the MIT License.
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify