Skip to content

kingkururu/endless_runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Endless Runner

A 2D endless runner game built with C++ and SFML, inspired by the Chrome dinosaur game. Features dynamic obstacle spawning, shooting mechanics, and challenging gameplay.

GAMEPLAY SCREENSHOT

Screenshot 2024-09-01 at 8 31 22 PM

Objective

Dodge as many slimes and bushes as possible while scoring points. The player can jump by pressing the spacebar and move up or down on the grass using the W and S keys. Bullets are fired with a mouse click and travel in the direction of the cursor, continuing off-screen. Successfully avoiding a bush or hitting a slime with a bullet increases the score by one point. The game ends if the player is hit by either a slime or a bush.

How to Play

  • Movement: Use W key to move up, S key to move down
  • Jumping: Press spacebar to jump over obstacles
  • Shooting: Click on screen to shoot bullets toward your cursor
  • Goal: Avoid or destroy obstacles to score points
  • Scoring: Each obstacle avoided or destroyed = 1 point

Technical Features

  • Architecture: Modular design with scenes system for improved organization
  • Physics: 2D raycasting, AABB collisions
  • Memory Management: Smart pointers with unique_ptr & shared_ptr for safer memory handling
  • Audio: Integrated sound effects and background music
  • Sprites: Sprite bitmask generation and class hierarchy modifications

Building & Running

Prerequisites

  • SFML 2.x library
  • C++ compiler (GCC/Clang)
  • Make

Installation

  1. Clone the repository:

    git clone https://github.com/kingkururu/endless_runner
    cd endless_runner (location will be different)
  2. Build the game:

    make
  3. Run the game:

    ./run

Alternative Setup (macOS with Homebrew)

  1. Install SFML:

    # Install Homebrew if not already installed
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
    # Install SFML
    brew install sfml@2
  2. Configure PATH (add to ~/.zshrc or ~/.bash_profile):

    export PATH="/opt/homebrew/bin:$PATH"
    export PATH="/opt/homebrew/opt/sfml@2/bin:$PATH"

Project Structure

endless_runner_sfml_game/
├── src/
│   ├── main.cpp
│   ├── game/
│   │   ├── game.cpp
│   │   ├── flags/
│   │   ├── physics/
│   │   ├── scenes/
│   │   ├── utils/
│   │   └── constants/
│   └── assets/
│       ├── fonts/
│       ├── sounds/
│       └── sprites/
├── Makefile
├── .gitignore
└── README.md

Assets

Sprites

Sound Effects

Font

Key Learning Outcomes

  • Game development fundamentals with SFML
  • Object-oriented programming in C++
  • Advanced C++ features (smart pointers, template metaprogramming)
  • 2D graphics rendering and sprite management
  • Real-time input handling and game loops
  • Multiple collision detection algorithms (AABB, raycasting)
  • Audio system integration

Game Mechanics

This Chrome dinosaur-inspired endless runner features:

  • Dynamic Difficulty: Slimes and bushes spawn at decreasing time intervals
  • Dual Combat System: Jump over obstacles or shoot them with bullets
  • Scoring System: 1 point per obstacle avoided or destroyed
  • Multi-directional Movement: Up/down movement plus jumping mechanics
  • Responsive Controls: Smooth movement and precise bullet targeting

Advanced Features

  • New scenes system: Flags/utils/constants class organization
  • Smart pointer implementation: Modern C++ memory management
  • Template metaprogramming: Advanced C++ techniques for generic collision handling
  • Modular architecture: Cleaner code separation with improved maintainability

About

Endless runner game built with SFML and C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published