Skip to content

Latest commit

 

History

30 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dino Run 2D

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.


Features

  • 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.

Game Controls

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

Directory Structure

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)

Requirements & Prerequisites

To build and run this project, you need:

  • A C++ compiler supporting C++11 or later (e.g., g++ / MinGW-w64 for Windows, clang for macOS, or gcc for 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.

Build and Run Instructions

Windows (Using MinGW-w64)

You can compile and start the game automatically using the provided batch file:

  1. Double-click start.bat in the root folder, or run it in your terminal:
    start.bat

Alternatively, you can compile manually using make inside the build directory:

  1. Open terminal and navigate to the build folder:
    cd build
  2. Build the project using mingw32-make or make:
    mingw32-make
  3. Run the compiled game:
    Game.exe

macOS / Linux

To build on macOS or Linux:

  1. Install Raylib on your system:
    • macOS (via Homebrew): brew install raylib
    • Debian/Ubuntu: sudo apt install libraylib-dev
  2. 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
  3. Run the compiled executable:
    ./Game

High Score & Player Stats

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).


License & Contributing

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!

About

a 2D Game written in C/C++ using Raylib.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages