A modular, component-based game engine built with C++20, featuring a terminal-based rendering system and two classic arcade games: Snake and Space Invaders.
This project is a comprehensive game engine implementation that demonstrates modern C++20 features, including modules, component-based architecture, and event-driven design. The engine provides a flexible foundation for building terminal-based games with features such as entity management, collision detection, input handling, rendering, and level management.
The engine is designed with extensibility in mind, allowing developers to create new games by extending the core GameEngine class and implementing game-specific logic. Currently, two fully-featured games are included as examples of the engine's capabilities.
- Entity-Component System: Flexible entity management with components for rendering, movement, collision, and boundaries
- Rendering System: Terminal-based graphics using ncurses with support for textures, pixels, and custom rendering
- Collision Detection: Configurable collision system with multiple collision types
- Input Management: Keyboard input handling with customizable controls
- Event System: Observer pattern-based event management for decoupled communication
- Time Management: Frame-rate independent game loop with delta time calculations
- Level Management: Configurable level system with progression support
- High Score System: Persistent high score tracking
- Boundary Management: Automatic boundary detection and handling
- Snake: Classic snake game with food collection, phantom mines, and progressive difficulty
- Space Invaders: Arcade-style space shooter with barriers, multiple alien types, and projectile combat
- Compiler: GCC 14+ with C++20 modules support
- Build System: Make
- Dependencies:
- ncurses library (for terminal graphics)
- Standard C++20 library
macOS:
brew install ncursesLinux (Ubuntu/Debian):
sudo apt-get install libncurses5-dev libncursesw5-devLinux (Fedora/RHEL):
sudo dnf install ncurses-devel- Clone the repository:
git clone <repository-url>
cd "actual engine"- Build all executables:
make allThis will create three executables:
age_engine- Main launcher with game selection menusnake_game- Standalone Snake gamespaceinvaders_game- Standalone Space Invaders game
make all- Build all executables (default)make engine- Build the main launchermake snake- Build Snake game onlymake spaceinvader- Build Space Invaders game onlymake clean- Remove all build artifacts
Run the main executable to select a game:
./age_engineYou'll be presented with a menu to choose between:
- Space Invaders
- Snake
Run games directly:
./snake_game
./spaceinvaders_gameThe engine follows a component-based architecture:
- GameEngine: Base class that manages core systems and the game loop
- Entity: Game objects with unique IDs and component attachments
- Components: Modular pieces of functionality (Render, Movement, Collision, etc.)
- Managers: System-level managers (EntityManager, CollisionManager, RenderManager, etc.)
- Controllers: Input handling and game logic controllers
- Views: Rendering abstraction (currently ncurses-based)
Games extend GameEngine and implement:
updateGameLogic()- Game-specific update logiconStart()- InitializationonStop()- CleanuppostRender()- Custom rendering
- Language: C++20 with modules
- Graphics: ncurses (terminal-based)
- Build System: Make
- Architecture: Component-based, event-driven
| Language | Files | Lines | Code | Comments | Blanks |
|---|---|---|---|---|---|
| C++ | 111 | 6,109 | 4,456 | 663 | 990 |
| Makefile | 1 | 203 | 145 | 29 | 29 |
| Total | 112 | 6312 | 4601 | 692 | 1019 |
Statistics generated using tokei
This project demonstrates modern C++20 game engine design patterns. When extending the engine:
- Create game-specific modules in their respective directories
- Extend the
GameEngineclass for new games - Use the component system for reusable functionality
- Follow the existing module structure (interface + implementation files)
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) [2025] [Rick Liu]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
