Space Invaders is a classic 2D arcade shooter game implemented in C++ using Windows console graphics. The game features a player-controlled spaceship that must shoot down waves of descending aliens before they reach the bottom of the screen.
├── spaceinvaders.cpp # Main game logic and engine
├── help.h # Graphics & input helper functions (Windows API-based)
- Full console-based graphics using Windows GDI
- Real-time keyboard input (no delays)
- Dynamic alien movement and shooting
- Player shooting with collision detection
- Score and lives tracking
- Game states: Menu, Playing, Game Over, Win
| Key | Action |
| ← / → | Move the player left/right |
| SPACE | Shoot bullets |
| ENTER | Start / Restart game |
| ESCAPE | Exit or go to menu |
- The game starts in the menu state.
- Pressing
Enterstarts the game, and the player can move and shoot aliens. - Each alien destroyed adds to your score.
- If all aliens are destroyed: You Win!
- If the player is hit 3 times or aliens reach the bottom: Game Over.
- Windows OS
- C++ compiler (MSVC recommended)
- Windows API and Console subsystem support
If using g++ (with Windows setup):
g++ spaceinvaders.cpp -o spaceinvaders -lgdi32Or using Visual Studio:
- Create a new Win32 Console Application project.
- Add
spaceinvaders.cppandhelp.hto the project. - Build and run.
- The game uses Windows-specific API functions such as
GetAsyncKeyState,SetConsoleCursorPosition, andGDIfor simple drawing. - This will not work on Linux/Mac terminals without porting.
This is a personal or academic project and is free to use and modify.
Developed with modern C++ principles to demonstrate data structure design, class organization, and logical gameplay programming.
We welcome contributions from the open-source community. If you'd like to collaborate on this project, please adhere to the following guidelines:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Implement your changes and commit them with descriptive messages.
- Push your branch to your fork and submit a pull request.