A modern, mobile-friendly implementation of the classic 2048 game built with React Native and Expo.
- Objective: Slide numbered tiles on a grid to combine them and reach the 2048 tile.
- Controls:
- Swipe: Use swipe gestures (up, down, left, right) to move tiles.
- Winning: Reach the 2048 tile to win the game.
- Game Over: The game ends when no moves are possible.
- Clone the repository:
cd The2048
- Install dependencies:
npm install
- Start the development server:
npx expo start
Follow the on-screen instructions to open the app in an emulator or on a physical device.
-
Game Logic:
- The game board is a 4x4 grid initialized with two random tiles.
- Tiles slide and merge according to 2048 game rules.
- The game checks for win and game-over conditions after each move.
- Functions like
slideLeft,slideRight,slideUp, andslideDownhandle movement and merging logic.
-
User Interface:
- The app features a responsive layout with a Midnight Neon theme.
- Includes modals for "How to Play" and game-over scenarios.
- Score tracking is displayed prominently.
- Board size is configurable from 2x2 to 8x8.
- Buttons for restarting and adjusting board size.
-
Technologies Used:
- React Native with Expo for cross-platform development.
- Gesture handling using
react-native-swipe-gestures. - State management using React's
useStateanduseMemo.
- Undo Feature: Allow players to undo their last move.
- High Score Tracking: Implement local storage to save high scores.
- Sound Effects: Add audio feedback for tile movements and merges.
- Multiplayer Mode: Enable two-player mode for competitive play.
- Themes: Offer additional color themes for customization.
- Name: Kartikey
- GitHub: https://github.com/kartikey004
- Email: kartikeym004@gmail.com