Welcome to the 2048 Game in C repository! This is a console-based version of the popular 2048 game, implemented in C using pointer arithmetic and a modular file structure. You can download the latest release here and execute the game in your terminal.
- Introduction
- Features
- Installation
- Usage
- Game Rules
- Code Structure
- Contributing
- License
- Acknowledgments
The 2048 game challenges players to combine tiles with the same number until they reach the tile with the number 2048. This project serves as an educational tool to understand C programming concepts, including pointer arithmetic and modular programming.
- Console-Based: Play directly in your terminal.
- Modular Design: The code is organized into multiple files for easier management.
- Pointer Arithmetic: Learn and apply pointer concepts in C.
- Educational: Ideal for those looking to improve their C programming skills.
- Cross-Platform: Runs on any system with a C compiler.
To get started, download the latest release from here. Follow these steps to install:
- Download the Release: Go to the releases section and download the appropriate file for your operating system.
- Extract the Files: Unzip the downloaded file to your desired location.
- Compile the Code: Open your terminal, navigate to the extracted folder, and run the following command:
make
- Run the Game: After compilation, execute the game using:
./2048
Once the game is running, you can use the arrow keys to move the tiles. The goal is to combine tiles with the same number to reach the 2048 tile. Here are the controls:
- Up Arrow: Move tiles up.
- Down Arrow: Move tiles down.
- Left Arrow: Move tiles left.
- Right Arrow: Move tiles right.
- Combine tiles with the same number to create a new tile with their sum.
- Each move generates a new tile with the value of 2 or 4.
- The game ends when there are no valid moves left.
- Try to reach the 2048 tile for victory!
The project follows a modular programming approach. Here's a brief overview of the file structure:
/2048-game-c
│
├── src/
│ ├── main.c # Main game loop
│ ├── game.c # Game logic
│ ├── display.c # Rendering the game board
│ ├── input.c # Handling user input
│ └── utils.c # Utility functions
│
├── include/
│ └── game.h # Header files for game functions
│
├── Makefile # Build script
└── README.md # Project documentation
- main.c: Contains the main function and game loop.
- game.c: Implements the core game logic, including tile merging and scoring.
- display.c: Manages how the game board is rendered in the terminal.
- input.c: Handles user inputs for tile movements.
- utils.c: Contains utility functions for various tasks.
Contributions are welcome! If you want to improve the game or add features, please follow these steps:
- Fork the repository.
- Create a new branch for your feature.
- Make your changes and commit them.
- Push your branch and create a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
- Special thanks to the open-source community for their invaluable resources.
- Inspired by the original 2048 game by Gabriele Cirulli.
For more updates and releases, check the Releases section.
Happy gaming!