Awesome
Console T-Rex Game
This is a console-based game inspired by the Google Chrome T-Rex dinosaur game, developed in C. The game provides a minimalistic experience with keyboard controls and a dynamic console interface.
Table of Contents
Features
- Console-based gameplay with simple ASCII graphics.
- Dynamic terminal resizing support.
- Player movement and obstacles, including an enemy and clouds.
- Score tracking.
- Day/Night cycle with sun, moon, and clouds.
Requirements
- Operating System: Unix-based systems (Linux, macOS).
- Dependencies:
- Standard C libraries (
stdlib.h
,stdio.h
, etc.). - Terminal control libraries (
ioctl
,unistd.h
).
- Standard C libraries (
Make sure you have a C compiler installed, like gcc
or clang
.
Installation
Arch Linux AUR Pakage installation :
yay -S trex-c
Installation from source files
-
Clone the repository:
git clone https://github.com/StiveMan1/T-RexC.git cd T-RexC
-
Compile the game:
gcc trex-c.c -O3 -lm -o trex-c
-
Run the game:
./trex-c
Usage
The game runs directly in the terminal. Use the following keys to control your character:
- Space bar: Jump and Start game
- Arrow Up: Jump and Start game
- Arrow Down: Crouch and Start game
- R: Restart in Spectator Mod
Gameplay
Avoid obstacles (represented by enemies on the screen) to keep your character alive. The score increases as you survive longer, with a higher score indicating better performance. Watch out for the changing day and night cycle, and use the jump function to avoid enemies and ground obstacles.
Configuration
Some gameplay and display elements can be configured:
- Game height and width: Automatically adapts to the console window size.
- Score: Displays in the top corner.
- Environment: Dynamic day/night cycle, clouds, sun, and moon.
Code Structure
dino.c
: Contains themain
function and game loop.update_console_events()
: Manages all screen updates, from player movement to obstacle generation and score display.keyboard_handler()
: Handles player inputs.draw_*()
functions: Render various elements like the player, obstacles, ground, and sky.
Contributing
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Open a Pull Request.
All contributions are welcome! Please follow the coding style found in the existing code and add comments where necessary.
License
This project is licensed under the GNU License. See the LICENSE file for details.