# samuel-chow-demon/cstp1205-spaceinvader architecture

> Architecture diagram of the GitHub repository samuel-chow-demon/cstp1205-spaceinvader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samuel-chow-demon/cstp1205-spaceinvader
- Repository: https://github.com/samuel-chow-demon/cstp1205-spaceinvader

## Overview

##### Project type and purpose
- This is a single‐process, Windows-Console-based 2D game application written in C++. It implements a Space Invaders–style game using the olcConsoleGameEngine for rendering “pixels” in a terminal window and standard Windows APIs for input and sound.

##### File structure
- Top‐level directory “GameConsoleInvader” holds all source (.cpp/.h), project files (.sln, .vcxproj), resources (.rc, .wav), and the single engine header (olcConsoleGameEngine.h).
- Key modules:
- Entry points: Demo.cpp, GameConsole.cpp
- Application & engine: CGameApp.*, CGameEngine.*
- Object factory: CEnemyFactory.*
- Game objects: CEnemy.*, CSpaceShip.*, CMissile.*, CDestroyAnime.*
- Utility: CoordUtility.h, CharacterSprite.h
- Sound subsystem: CSound.*
- No external microservices or databases—everything runs in one thread inside a console process.

##### Extract insights from the README
- Single‐threaded main loop with sleep(1) timing.
- 3-frame explosion animation.
- Provided UML and flowcharts for game flow, spaceship & enemy behaviors.

##### Detail without over-fragmentation
- Every class/module listed in the file tree.
- Related classes visually (e.g., put all “GameObj” classes in one cluster).
- Don’t omit the olcConsoleGameEngine – it is the rendering/input backbone.
- One‐life rule & level progression as part of the GameApp flow if space permits.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Entry Points
    subgraph "Entry Points"
        direction TB
        Entry1["GameConsole.cpp"]:::entry
        Entry2["Demo.cpp"]:::entry
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        App["CGameApp"]:::app
    end

    %% Engine Layer
    subgraph "Engine Layer"
        direction TB
        Engine["CGameEngine"]:::engine
        Renderer["olcConsoleGameEngine"]:::engine
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        Factory["CEnemyFactory"]:::factory
        subgraph "Game Entities"
            direction TB
            Ship["CSpaceShip"]:::domain
            Enemy["CEnemy"]:::domain
            Missile["CMissile"]:::domain
            DestroyAnim["CDestroyAnime"]:::domain
        end
        Attributes["GameObjAttribute"]:::domain
    end

    %% Utilities
    subgraph "Utilities"
        direction TB
        CoordUtil["CoordUtility"]:::util
        CharSprite["CharacterSprite"]:::util
    end

    %% Sound Subsystem
    subgraph "Sound Subsystem"
        direction TB
        Sound["CSound"]:::sound
        SoundFiles["Sound Resources"]:::resource
    end

    %% Resources
    subgraph "Resources"
        direction TB
        RC["GameConsole.rc & resource.h"]:::resource
    end

    %% Connections
    Entry1 -->|starts| App
    Entry2 -->|starts| App
    App -->|initializes| Engine
    Engine -->|uses| Renderer
    Engine -->|handles input| Ship
    Engine -->|spawns via| Factory
    Factory -->|creates| Enemy
    Engine -->|update/draw| Ship
    Engine -->|update/draw| Enemy
    Engine -->|update/draw| Missile
    Engine -->|update/draw| DestroyAnim
    Enemy -->|uses| Attributes
    Ship -->|uses| Attributes
    Missile -->|uses| Attributes
    DestroyAnim -->|uses| Attributes
    Ship -->|uses| CharSprite
    Enemy -->|uses| CharSprite
    Missile -->|uses| CharSprite
    DestroyAnim -->|uses| CharSprite
    Engine -->|plays sound| Sound
    Sound -->|loads| SoundFiles
    App -->|loads| RC

    %% Click Events
    click Entry1 "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/GameConsole.cpp"
    click Entry2 "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/Demo.cpp"
    click App "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CGameApp.h"
    click Engine "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CGameEngine.h"
    click Renderer "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/olcConsoleGameEngine.h"
    click Factory "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CEnemyFactory.h"
    click Ship "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CSpaceShip.h"
    click Enemy "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CEnemy.h"
    click Missile "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CMissile.h"
    click DestroyAnim "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CDestroyAnime.h"
    click Attributes "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/GameObjAttribute.h"
    click Sound "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CSound.h"
    click SoundFiles "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/tree/main/GameConsoleInvader/sound/"
    click CoordUtil "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CoordUtility.h"
    click CharSprite "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/CharacterSprite.h"
    click RC "https://github.com/samuel-chow-demon/cstp1205-spaceinvader/blob/main/GameConsoleInvader/GameConsole.rc"

    %% Styles
    classDef entry fill:#D3D3D3,stroke:#666,stroke-width:1px;
    classDef app fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef engine fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef domain fill:#98FB98,stroke:#333,stroke-width:1px;
    classDef factory fill:#FFA500,stroke:#333,stroke-width:1px;
    classDef util fill:#FFDEAD,stroke:#333,stroke-width:1px;
    classDef sound fill:#DDA0DD,stroke:#333,stroke-width:1px;
    classDef resource fill:#DDA0DD,stroke:#333,stroke-width:1px;
```
