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.
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.
- Movement: Use
Wkey to move up,Skey to move down - Jumping: Press
spacebarto 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
- 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
- SFML 2.x library
- C++ compiler (GCC/Clang)
- Make
-
Clone the repository:
git clone https://github.com/kingkururu/endless_runner cd endless_runner (location will be different) -
Build the game:
make
-
Run the game:
./run
-
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
-
Configure PATH (add to ~/.zshrc or ~/.bash_profile):
export PATH="/opt/homebrew/bin:$PATH" export PATH="/opt/homebrew/opt/sfml@2/bin:$PATH"
endless_runner_sfml_game/
├── src/
│ ├── main.cpp
│ ├── game/
│ │ ├── game.cpp
│ │ ├── flags/
│ │ ├── physics/
│ │ ├── scenes/
│ │ ├── utils/
│ │ └── constants/
│ └── assets/
│ ├── fonts/
│ ├── sounds/
│ └── sprites/
├── Makefile
├── .gitignore
└── README.md
- Main player sprite: Free Pixel Art Tiny Hero Sprites
- Bushes: Free Top Down Bushes Pixel Art
- Slime: Free Slime Sprite Sheets Pixel Art
- Forest background: Free Cartoon Forest Game Backgrounds
- Background music: Retro Game Arcade Music
- Player dead sound: Game Over Sound Effect
- Bullet sound: Bullet Firing Sound
- Pixel font: Pixel Font Collection
- 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
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
- 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