Skip to content
rick-mingyu-liuPublic

About

Terminal game engine in C++20 with modules and an entity-component system — rendering, collision, events, a delta-time loop, levels and high scores. Snake and Space Invaders are built on it.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

73 Commits

Folders and files

Repository files navigation

AGE Game Engine

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.

Introduction

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.

Features

Core Engine Systems

  • 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

Included Games

  1. Snake: Classic snake game with food collection, phantom mines, and progressive difficulty
  2. Space Invaders: Arcade-style space shooter with barriers, multiple alien types, and projectile combat

Requirements

  • Compiler: GCC 14+ with C++20 modules support
  • Build System: Make
  • Dependencies:
    • ncurses library (for terminal graphics)
    • Standard C++20 library

Installing Dependencies

macOS:

brew install ncurses

Linux (Ubuntu/Debian):

sudo apt-get install libncurses5-dev libncursesw5-dev

Linux (Fedora/RHEL):

sudo dnf install ncurses-devel

Building

  1. Clone the repository:
git clone <repository-url>
cd "actual engine"
  1. Build all executables:
make all

This will create three executables:

  • age_engine - Main launcher with game selection menu
  • snake_game - Standalone Snake game
  • spaceinvaders_game - Standalone Space Invaders game

Build Targets

  • make all - Build all executables (default)
  • make engine - Build the main launcher
  • make snake - Build Snake game only
  • make spaceinvader - Build Space Invaders game only
  • make clean - Remove all build artifacts

Running

Main Launcher

Run the main executable to select a game:

./age_engine

You'll be presented with a menu to choose between:

  1. Space Invaders
  2. Snake

Individual Games

Run games directly:

./snake_game
./spaceinvaders_game

Engine Structure

UML Diagram

Architecture

The 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 logic
  • onStart() - Initialization
  • onStop() - Cleanup
  • postRender() - Custom rendering

Technology Stack

  • Language: C++20 with modules
  • Graphics: ncurses (terminal-based)
  • Build System: Make
  • Architecture: Component-based, event-driven

Code Statistics

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

Contributing

This project demonstrates modern C++20 game engine design patterns. When extending the engine:

  1. Create game-specific modules in their respective directories
  2. Extend the GameEngine class for new games
  3. Use the component system for reusable functionality
  4. Follow the existing module structure (interface + implementation files)

License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

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.

About

Terminal game engine in C++20 with modules and an entity-component system — rendering, collision, events, a delta-time loop, levels and high scores. Snake and Space Invaders are built on it.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages