A classic 2D endless-runner arcade game built in C++ using the Raylib library. Control a dinosaur, dodge incoming tree obstacles, experience dynamic day-and-night cycles, and try to beat the high score!
This project was originally developed as a final project for CS-172.
- Dynamic Gameplay: Face randomly spaced obstacles that speed up as your score increases, testing your reflexes.
- Day & Night Cycle: The environment switches between day (morning) and night modes dynamically every 500 points.
- Audio & SFX: Retro-style sound effects for jumping, scoring, game over, and winning, accompanied by background music.
- Persistent Stats: Automatically tracks and persists game statistics (high score, average score, sessions, and attempts) locally in a CSV file format.
- Pause & Resume: Pause the action at any time with a dedicated key bind.
| Key / Control | Action |
|---|---|
[SPACEBAR] |
Jump over obstacles |
[P] |
Pause / Resume the game |
[ENTER] |
Restart / Play again after Game Over or Win |
[ESC] / Close Window |
Exit game |
Quit Game Button |
Click with Left Mouse Button on Game Over / Win screen to exit |
dinorun.c/ # Repository Root (C++ project)
├── .vscode/ # VS Code project configurations
├── assets/ # Game assets
│ ├── audio/ # Sound effects (wav) and background music (mp3)
│ └── sprites/ # Textures and character sprites (png)
├── build/ # Build scripts and compiled executables
│ ├── Game.exe # Windows compiled executable
│ └── Makefile # Makefile for compiling the project
├── data/ # Local storage and persistent database
│ └── stats.csv # CSV tracking player stats and scores
├── headers/ # C++ header files
│ ├── game.h # Core Game class declaration and structure definitions
│ └── utils.h # Helper functions (UI buttons, centralized text drawing)
├── include/ # Raylib library headers (for Windows MinGW build)
├── lib/ # Pre-compiled static libraries for Raylib (Windows)
├── source/ # C++ source code files
│ ├── game.cpp # Main game state updates, rendering, and logic
│ └── main.cpp # Main entry point, stats file loader, and saver
├── start.bat # Batch script for Windows to compile and run
└── README.md # Project documentation (this file)
To build and run this project, you need:
- A C++ compiler supporting C++11 or later (e.g.,
g++/ MinGW-w64 for Windows,clangfor macOS, orgccfor Linux). - Raylib Library:
- The repository includes pre-compiled Raylib headers (
include/) and static libraries (lib/libraylib.a) for Windows. - For other platforms (macOS / Linux), you must install Raylib system-wide or compile it from source.
- The repository includes pre-compiled Raylib headers (
You can compile and start the game automatically using the provided batch file:
- Double-click
start.batin the root folder, or run it in your terminal:start.bat
Alternatively, you can compile manually using make inside the build directory:
- Open terminal and navigate to the
buildfolder:cd build - Build the project using
mingw32-makeormake:mingw32-make
- Run the compiled game:
Game.exe
To build on macOS or Linux:
- Install Raylib on your system:
- macOS (via Homebrew):
brew install raylib - Debian/Ubuntu:
sudo apt install libraylib-dev
- macOS (via Homebrew):
- Update the compilation flags to link against your system's Raylib installation. You can run a command similar to:
g++ source/*.cpp -o Game -O2 -Wall -Iheaders -lraylib - Run the compiled executable:
./Game
The game records and saves stats to data/stats.csv under the following keys:
- High Score: The highest score achieved across all play sessions.
- Average Score: Average score achieved.
- Average Score per Session: Normalized score per play session.
- Number of Sessions: Total game execution times.
- Number of Attempts: Total retries/attempts.
Note: The game loads and saves player stats using the relative path ../data/stats.csv. Therefore, the compiled executable MUST be run from within the build/ directory for the stats to load and persist correctly (as automated by start.bat).
This project is open-source. Feel free to fork the repository, report bugs, suggest features, or submit pull requests to improve the Dino Run experience!