Twos
Difficulty: Hard
In this exercise, you will implement a simplified version of the 2048 game using a 4x4 grid. Your goal is to develop a functional and optimized solution that manages tile merging, movement logic, game state updates, and user interactions effectively.
Game Mechanics
- The game begins with two randomly placed tiles, each with a value of 2 or 4.
- Swipe gestures (up, down, left, right) move all tiles in the chosen direction.
- When two tiles with the same value collide, they merge into one, doubling their value.
- After every valid move, a new tile (2 or 4) appears in a random empty cell.
- The game ends when no valid moves remain (loss) or when a tile reaches 2048 (win).
- For testing purposes, you may lower the win condition to 32 or 64 to validate functionality faster.
Additional Requirements
Status Label
Display game messages when necessary:
- "You won!" when a tile reaches 2048.
- "Game Over!" when no moves are possible.
New Game Button
- Resets the game board to its initial state with two random tiles.
- Clears any win/loss messages.
Above & Beyond
Ensure smooth tile movement and merging animations.