# techwithtim/tower-defense-game architecture

> Architecture diagram of the GitHub repository techwithtim/tower-defense-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/techwithtim/tower-defense-game
- Repository: https://github.com/techwithtim/tower-defense-game

## Overview

##### Main Components

a) Core Game Components:
- Game Engine (game.py as the central controller)
- Tower System
- Enemy System
- Menu System

##### Component Breakdown and Relationships

a) Enemy System:
- Derived enemy types (club.py, scorpion.py, sword.py, wizard.py)

b) Tower System:
- Base Tower class (tower.py)
- Derived tower types (archerTower.py, supportTower.py)

c) Menu System:
- Main Menu component (main_menu/main_menu.py)
- Game Menu component (menu/menu.py)
- Their interaction with the game engine

**[Game Engine]**

- ┬─────────────────┐

**[Tower System]   [Enemy System]   [Menu System]**

**[Tower Types]    [Enemy Types]    [Menu Types]**

##### Additional Details

- Pygame as the underlying framework
- Entry point (run.py)
- Main game controller (game.py)
- How the different systems communicate with each other

##### Implementation Notes

- Brief notes about the real-time nature of the game
- Event handling flow between components

Remember to add a note about the asset management system, even though the assets aren't publicly available (as mentioned in the README), as it's still an important architectural consideration.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core
        GE[Game Engine]
        EP[Entry Point]
    end

    subgraph "Enemy System"
        BE[Base Enemy]
        CE[Club Enemy]
        SE[Scorpion Enemy]
        SWE[Sword Enemy]
        WE[Wizard Enemy]
    end

    subgraph "Tower System"
        BT[Base Tower]
        AT[Archer Tower]
        ST[Support Tower]
    end

    subgraph "Menu System"
        MM[Main Menu]
        GM[Game Menu]
    end

    %% Core relationships
    EP --> GE
    GE --> BE
    GE --> BT
    GE --> MM
    GE --> GM

    %% Enemy inheritance
    BE --> CE
    BE --> SE
    BE --> SWE
    BE --> WE

    %% Tower inheritance
    BT --> AT
    BT --> ST

    %% Menu interactions
    MM -.-> GM
    GM -.-> GE

    %% Click events
    click EP "https://github.com/techwithtim/Tower-Defense-Game/blob/master/run.py"
    click GE "https://github.com/techwithtim/Tower-Defense-Game/blob/master/game.py"
    click BE "https://github.com/techwithtim/Tower-Defense-Game/blob/master/enemies/enemy.py"
    click CE "https://github.com/techwithtim/Tower-Defense-Game/blob/master/enemies/club.py"
    click SE "https://github.com/techwithtim/Tower-Defense-Game/blob/master/enemies/scorpion.py"
    click SWE "https://github.com/techwithtim/Tower-Defense-Game/blob/master/enemies/sword.py"
    click WE "https://github.com/techwithtim/Tower-Defense-Game/blob/master/enemies/wizard.py"
    click BT "https://github.com/techwithtim/Tower-Defense-Game/blob/master/towers/tower.py"
    click AT "https://github.com/techwithtim/Tower-Defense-Game/blob/master/towers/archerTower.py"
    click ST "https://github.com/techwithtim/Tower-Defense-Game/blob/master/towers/supportTower.py"
    click MM "https://github.com/techwithtim/Tower-Defense-Game/blob/master/main_menu/main_menu.py"
    click GM "https://github.com/techwithtim/Tower-Defense-Game/blob/master/menu/menu.py"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef enemy fill:#e74c3c,stroke:#c0392b,color:white
    classDef tower fill:#2ecc71,stroke:#27ae60,color:white
    classDef menu fill:#f1c40f,stroke:#f39c12,color:white

    class GE,EP core
    class BE,CE,SE,SWE,WE enemy
    class BT,AT,ST tower
    class MM,GM menu

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Enemy Components]:::enemy
        L3[Tower Components]:::tower
        L4[Menu Components]:::menu
        L5["--> Direct Dependency"]
        L6["-.-> Indirect Interaction"]
    end
```
