Made just for fun. Play it here!
2048 is a single-player puzzle game where players combine tiles with the same number to gradually achieve higher numbers, with the goal of reaching 2048. The gameplay is simple but challenging, requiring players to think about how to merge tiles efficiently while managing limited space to avoid a game over.
In this project, we will implement a web-based version of the 2048 game, allowing players to play through their browsers using keyboard controls.
- Game Board: The game board is a 4x4 grid, where each position can hold a number (2, 4, 8, 16, 32, etc.).
- Tile Merging Rule: Players slide tiles in four directions (up, down, left, right) to combine tiles with the same number. The merged tile's value will be doubled.
- New Tile Generation: After each move, a new tile (either 2 or 4) will randomly appear in an empty space.
- Game Over: The game ends when no valid moves are left. Players must avoid filling the board and having no tiles left to combine.
- Score: Every time tiles are merged, the player earns points equal to the value of the newly formed tile.
- Starting State: The game starts with two tiles placed randomly on the board, each with a value of either 2 or 4.
- Controls: Players control the tiles using the arrow keys (up, down, left, right).
- Merging Rule:
- Tiles with the same number can only merge once.
- The merged tile will have a value equal to the sum of the two merged tiles.
- Tile Generation: After each move, a new tile (2 or 4) will randomly appear in an empty space.
- Game Over: The game ends when there are no valid moves left on the board.
A small clone of 1024, based on Saming's 2048 (also a clone). 2048 was indirectly inspired by Threes.
Anna Harren and sigod are maintainers for this repository.
Other notable contributors:
- TimPetricola added best score storage
- chrisprice added custom code for swipe handling on mobile
- marcingajda made swipes work on Windows Phone
- mgarciaisaia added support for Android 2.3
Many thanks to rayhaanj, Mechazawa, grant, remram44 and ghoullier for the many other good contributions.
Changes and improvements are more than welcome! Feel free to fork and open a pull request. Please make your changes in a specific branch and request to pull into master! If you can, please make sure the game fully works before sending the PR, as that will help speed up the process.
2048 is licensed under the MIT license.
