Game Overview
Objective Gameplay
The goal of the 2048 game is to combine tiles with the same When two tiles with the same number touch, they merge
numbers to create a tile with the number 2048. Players slide into a single tile with a larger number. The challenge is to
tiles in any direction—up, down, left, or right—and new tiles keep the grid from filling up while working toward higher
appear after every move. numbers.
2048 Game Project Report
This report presents the design, implementation, and output screens of
a 2048 game developed by a team of students under the guidance of Ms.
Durga Pavani.
• P Abhinaya Gayatri(24R11A05D6)
• R Bhaavani Reddy(24R11A05E1)
• Vaibhav(24R11A05 )
System Requirements
Hardware Software
• RAM: 1GB • Operating System:
• Hard Disk: 80GB Windows XP
• Processor: Pentium • IDE: Turbo C or Visual
Studio Code
Game Logic
Move Validation
The game checks if a move is valid before executing it. A move is valid if it results in at least one tile moving or combining.
Tile Movement
When a player makes a move, the tiles are shifted in the specified direction. If two tiles with the same number collide, they merge into a single tile with a
doubled value.
New Tile Spawn
After each valid move, a new tile with a value of 2 or 4 is spawned at a random empty position on the board.
Game Design
Algorithm for 2048 Game:
•Perform the move:
1.Start
• Based on the player's input, shift the tiles:
2.Initialize the board: • Move Up: Combine and shift tiles upward.
• Set all grid cells to 0. • Move Down: Combine and shift tiles downward.
• Move Left: Combine and shift tiles to the left.
3.Spawn the first tile: • Move Right: Combine and shift tiles to the right.
• Add a tile with a value of 2 or 4 at a random empty position on the • If no tiles moved or combined during the move, go back to input.
grid.
•Spawn a new tile:
4.Game Loop: • Add a new tile (2 or 4) at a random empty position.
• Print the board: Display the current state of the board (“.” if 0).
• Check for game over:
• If no moves are possible or no empty cells remain, display "Game
5.Repeat the game loop until the player quits or the game ends.
Over" and exit the game.
•Input move:
• Ask the player for a move: Up (1), Down (2), Left (3), Right (4), or
Quit (0). 6.End
•Validate input:
• If the input is invalid, prompt the player again.
• If the input is 0, exit the game.
Implementation Details
Game Output Screens
Conclusion
The 2048 game is a simple yet challenging puzzle game that requires
strategic thinking and planning. The implementation of the game
involves a game loop, move validation, tile movement, and new tile
spawning. The game is designed to be user-friendly and provides a fun
and engaging experience for players of all ages.