A 2D space shooter game built with modern C++ and OpenGL. Navigate through space, battle enemies, and survive in this action-packed arcade-style game!
- 2D Space Combat: Control your spaceship and battle enemy ships
- Multiple Enemy Types: Various AI-controlled enemies with different behaviors
- Parallax Scrolling: Beautiful layered background effects for depth
- Dynamic Audio: Sound effects and background music
- Health System: Player health with regeneration mechanics
- Bullet Physics: Realistic projectile system with collision detection
- Scalable Difficulty: Enemies spawn with increasing difficulty over time
- Language: C++ (C++17)
- Graphics: OpenGL with GL2D renderer
- Audio: raudio library
- Input: GLFW for window management and input handling
- Math: GLM (OpenGL Mathematics)
- Build System: CMake
- Libraries Used:
- GLFW 3.3.2 - Window and input management
- GLAD - OpenGL function loading
- GLM - Mathematics library
- stb_image - Image loading
- stb_truetype - Font rendering
- raudio - Audio playback
- Dear ImGui - Debug UI (optional)
- ENet - Networking capabilities
SpaceWar Game in CPP/
├── src/
│ ├── gameLayer/ # Core game logic
│ │ ├── gameLayer.cpp # Main game loop and logic
│ │ ├── bullet.cpp # Bullet physics and rendering
│ │ ├── enemy.cpp # Enemy AI and behavior
│ │ └── tiledRenderer.cpp # Background rendering
│ └── platform/ # Platform-specific code
│ ├── glfwMain.cpp # Application entry point
│ ├── platformInput.cpp # Input handling
│ └── opterPlatformFunctions.cpp # Utility functions
├── include/ # Header files
├── resources/ # Game assets
│ ├── spaceShip/ # Ship sprites and animations
│ ├── space/ # Space backgrounds and objects
│ ├── background*.png # Parallax background layers
│ ├── health*.png # Health UI elements
│ └── *.flac # Audio files
├── thirdparty/ # External libraries
└── CMakeLists.txt # Build configuration
- CMake (3.10 or higher)
- C++ Compiler with C++17 support:
- Visual Studio 2019/2022 (Windows)
- GCC 7+ (Linux)
- Clang 6+ (macOS)
-
Clone the repository:
git clone <repository-url> cd "SpaceWar Game in CPP"
-
Generate build files:
cmake -S . -B build -
Build the project:
cmake --build build --config Release
-
Run the game:
- The executable will be in
build/Release/ - Make sure the
resources/folder is in the same directory as the executable
- The executable will be in
For Visual Studio users:
cmake -S . -B build -G "Visual Studio 17 2022"
cmake --build build --config Release- Movement: WASD or Arrow Keys
- Aim: Mouse cursor
- Shoot: Left Mouse Button
- Exit: ESC key
- Move freely in 2D space
- Aim with mouse cursor
- Shoot projectiles at enemies
- Health regenerates slowly over time
- Game over when health reaches zero
- Spawn randomly around the player
- Different ship types with varying:
- Speed and maneuverability
- Fire rate and bullet speed
- Health and durability
- AI that pursues and attacks the player
- Despawn when too far from player
- Projectile-based combat system
- Collision detection between bullets and ships
- Health system for both player and enemies
- Audio feedback for shooting and impacts
- Fonts: CommodorePixeled.ttf
- Graphics: Custom space ship sprites and UI elements
- Audio: Sound effects for shooting and ambient audio
This project demonstrates:
- Modern C++ game development practices
- OpenGL 2D rendering techniques
- Entity-component-like architecture
- Audio integration in games
- CMake build system setup
- Cross-platform game development
Feel free to submit issues and enhancement requests!
This project is for educational purposes. Please check individual library licenses in the thirdparty/ directory.
Original Tutorial: Based on the YouTube video by meemknight.
CMake Setup Tutorial: CMake Setup Video
Part 2 Tutorial: Adding Menu System







