Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FPS game (C++ / SDL2)

A top-down shooter built in C++ using SDL2, with multiple enemy types, weapon progression, pickups, levels, UI states, and sprite-based rendering.

Gameplay

Features

  • Top-down movement and shooting
  • Multiple weapons (pistol, rifle, shotgun, machinegun)
  • Enemy variety (horizontal, vertical, smart/chasing)
  • Item pickups (health, speed boost, weapons)
  • Inventory and weapon switching
  • Level progression + game over flow
  • Texture/sprite rendering for player, enemies, walls, floor, and items

Tech Stack

  • C++20
  • SDL2
  • SDL2_image
  • SDL2_ttf
  • CMake

Project Structure

  • SDL/ — main game source code
  • SDL/sprites/ — game assets (textures/sprites)
  • SDL/build/ — local build output
  • SDL/tests/ — C++ test files (weapon, enemy, player, menu)

Build & Run (macOS)

1) Install dependencies

brew install cmake pkg-config sdl2 sdl2_image sdl2_ttf

2) Configure + build

cd SDL
cmake -S . -B build
cmake --build build -j

3) Run

cd build
./fps

Tests

Configure + build tests

cd SDL
cmake -S . -B build
cmake --build build -j4

Run all tests

ctest --test-dir build --output-on-failure

Run one test target

ctest --test-dir build -R weapon_tests --output-on-failure
ctest --test-dir build -R enemy_tests --output-on-failure
ctest --test-dir build -R player_tests --output-on-failure
ctest --test-dir build -R menu_tests --output-on-failure

Current test targets

  • weapon_tests — weapon stats, cooldown/reload, spread, level mapping
  • enemy_tests — enemy movement/stats/difficulty/damage and score increment logic
  • player_tests — player collision damage + invulnerability behavior
  • menu_tests — menu click action mapping + click debounce behavior

Continuous Integration (GitHub Actions)

This repo includes a CI workflow at .github/workflows/ci.yml.

On every push and pull request, CI will:

  1. Install SDL2 dependencies on Ubuntu
  2. Configure with CMake (cmake -S . -B build)
  3. Build (cmake --build build -j4)
  4. Run tests (ctest --test-dir build --output-on-failure)

To view results on GitHub:

  • Open repository page
  • Go to the Actions tab
  • Open the latest CI run

Controls

  • W A S D — move
  • Mouse Left Click — shoot
  • R — reload
  • Space — melee
  • E — open/close inventory
  • 1 / 2 / 3 / 4 — switch weapon (when unlocked)
  • Esc — pause/unpause / back from some menus
  • Enter — continue next level / restart from game over
  • G — reset high score on game-over screen

Roadmap Ideas

  • Add sound effects and music
  • Add enemy hit feedback and damage popups
  • Add save/load for progression
  • Package releases for GitHub/itch.io

// console version (for testing game logic without graphics)

RUN (ONLY ON MAC)

g++ -std=c++11 main.cpp -lncurses -o main

THEN

./main

About

A first person shooter built in C++ using SDL2, with multiple enemy types, weapon progression, pickups, levels, UI states, and sprite-based rendering.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Packages

Contributors

Languages