# hdescottes/gdxgame architecture

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

- Interactive diagram: https://gitdiagram.com/hdescottes/gdxgame
- Repository: https://github.com/hdescottes/gdxgame

## Overview

##### Project type and purpose
- This is a 2D RPG game built on the LibGDX framework. It uses a multi‐module Gradle setup with:
- core – the game engine and logic
- desktop – the desktop launcher and platform glue
- Features include map rendering, entity/component system, turn-based battle, inventory, quests, profiles, and UI screens.

##### File structure
- Top‐level modules:
- core/src/main/java/com/gdx/game – all game subsystems (animation, audio, battle, camera, component, dialog, entities, inventory, manager, map, profile, quest, screen, status)
- desktop – platform launcher (DesktopLauncher)
- Resources in core/src/main/resources: assets (images, maps, JSON scripts), fonts, music, Tiled map files, conversation & quest data.
- Uses Observer pattern heavily (Subject/Observer pairs in audio, battle, inventory, profile, status, dialog, class system).
- Uses a Component‐based entity system (GraphicsComponent, PhysicsComponent, InputComponent).

##### README for additional insights
- Confirms LibGDX, RPG features, Level Up, Inventory, Battle, Class Tree, automatic saving.
- Mentions resource files produced by Tiled, JSON for quests/conversations, use of `AnimationManager`, `ResourceManager`, `PreferenceManager`.

##### Detailed capture of essential elements
- Component pattern: Entities composed of multiple components updated by respective subsystems.
- Observer connections for at least one example from each domain (battle, inventory, audio, profile).
- Screen transition flow: Menu → Game → Battle → GameOver → Back to Menu.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Layer
    subgraph "Platform"
        DL["DesktopLauncher"]:::platform
    end

    %% Core Engine
    subgraph "Core Engine"
        GG["GdxGame"]:::core
        RM["ResourceManager"]:::manager
        PM["PreferenceManager"]:::manager
    end

    %% Screen Management
    subgraph "UI & Screens" 
        SM["ScreenManager"]:::controller
        BS["BaseScreen"]:::controller
        MS["MenuScreen"]:::controller
        GS["GameScreen"]:::controller
        BSS["BattleScreen"]:::controller
        OS["OptionScreen"]:::controller
        BUI["BattleUI"]:::ui
        IUI["InventoryUI"]:::ui
        QU["QuestUI"]:::ui
        SUI["StatusUI"]:::ui
        DUI["DialogUI"]:::ui
    end

    %% Subsystems & Managers
    subgraph "Subsystems & Managers"
        IS["Input Subsystem"]:::subsys
        RS["Rendering Subsystem"]:::subsys
        PS["Physics Subsystem"]:::subsys
        AS["Audio Subsystem"]:::subsys
        EM["Entity Management"]:::subsys
        MM["Map Management"]:::subsys
        INV["Inventory Subsystem"]:::subsys
        BAT["Battle Subsystem"]:::subsys
        QST["Quest Subsystem"]:::subsys
        PROF["Profile Subsystem"]:::subsys
    end

    %% Entities & Components
    subgraph "Entities & Components"
        EF["EntityFactory"]:::entity
        E["Entity"]:::entity
        GC["GraphicsComponent"]:::component
        PC["PhysicsComponent"]:::component
        IC["InputComponent"]:::component
    end

    %% Data Layer
    subgraph "Data & Resources"
        ASSETS["Assets (sprites, maps, JSON, music)"]:::data
    end

    %% External Libraries
    subgraph "External"
        LGDX["LibGDX"]:::external
    end

    %% Connections
    DL -->|"launches"| GG
    LGDX -->|"provides API"| GG
    GG -->|"initializes"| RM
    GG -->|"initializes"| PM
    GG -->|"manages screens"| SM
    SM --> BS
    BS --> MS
    BS --> GS
    BS --> BSS
    BS --> OS
    GS -->|"uses"| IS
    GS -->|"uses"| RS
    GS -->|"uses"| PS
    GS -->|"uses"| EM
    GS -->|"uses"| MM
    GS -->|"uses"| AS
    GS -->|"uses"| RM
    GS -->|"uses"| PM

    %% Subsystems interactions
    RM --> RS
    RM --> AS
    RM --> MM
    RM --> QST
    RM --> PROF
    IS --> IC
    RS --> GC
    PS --> PC
    AS -->|"notify"| BAT
    AS -->|"notify"| INV
    AS -->|"notify"| PROF
    EM --> EF
    EM --> E
    MM -->|"loads maps"| ASSETS
    QST -->|"reads scripts"| ASSETS
    PROF -->|"saves data to"| ASSETS
    INV -->|"manages items"| ASSETS
    BAT -->|"manages state"| BAT
    BAT -->|"updates UI"| BUI
    BAT -->|"notifies"| BAT
    PROF -->|"notifies UI"| SUI
    INV -->|"notifies UI"| IUI
    AS -->|"notifies UI"| BUI

    %% Entity-Component connections
    EF --> E
    E --> GC
    E --> PC
    E --> IC

    %% UI connections
    GS --> BUI
    GS --> IUI
    GS --> QU
    GS --> SUI
    GS --> DUI

    %% Click Events
    click DL "https://github.com/hdescottes/gdxgame/blob/master/desktop/src/main/java/com/gdx/game/desktop/DesktopLauncher.java"
    click GG "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/GdxGame.java"
    click BS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/screen/BaseScreen.java"
    click MS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/screen/MenuScreen.java"
    click GS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/screen/GameScreen.java"
    click BSS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/screen/BattleScreen.java"
    click OS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/screen/OptionScreen.java"
    click IC "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/component/InputComponent.java"
    click IS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/common/DefaultControlsMap.java"
    click GC "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/component/GraphicsComponent.java"
    click RM "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/manager/AnimationManager.java"
    click GG "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/animation/AnimatedImage.java"
    click PC "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/component/PhysicsComponent.java"
    click AS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/audio/AudioManager.java"
    click AS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/audio/AudioSubject.java"
    click AS "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/audio/AudioObserver.java"
    click EF "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/entities/EntityFactory.java"
    click E "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/entities/Entity.java"
    click MM "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/map/MapManager.java"
    click MM "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/map/MapFactory.java"
    click BUI "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/battle/BattleUI.java"
    click IUI "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/inventory/InventoryUI.java"
    click QU "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/quest/QuestUI.java"
    click SUI "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/status/StatusUI.java"
    click DUI "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/dialog/ConversationUI.java"
    click INV "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/inventory/InventorySubject.java"
    click INV "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/inventory/InventoryObserver.java"
    click BAT "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/battle/BattleSubject.java"
    click BAT "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/battle/BattleObserver.java"
    click BAT "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/battle/BattleState.java"
    click BAT "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/battle/BattleUtils.java"
    click BAT "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/battle/BattleHUD.java"
    click QST "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/quest/QuestGraph.java"
    click QST "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/quest/QuestTaskHandler.java"
    click PROF "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/profile/ProfileManager.java"
    click PROF "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/profile/ProfileSubject.java"
    click PROF "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/profile/ProfileObserver.java"
    click RM "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/manager/ResourceManager.java"
    click PM "https://github.com/hdescottes/gdxgame/blob/master/core/src/main/java/com/gdx/game/manager/PreferenceManager.java"

    %% Styles
    classDef platform fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef core fill:#add8e6,stroke:#333,stroke-width:1px
    classDef manager fill:#f4a460,stroke:#333,stroke-width:1px
    classDef controller fill:#90ee90,stroke:#333,stroke-width:1px
    classDef ui fill:#98fb98,stroke:#333,stroke-width:1px
    classDef subsys fill:#ffa500,stroke:#333,stroke-width:1px
    classDef entity fill:#ffffe0,stroke:#333,stroke-width:1px
    classDef component fill:#fffacd,stroke:#333,stroke-width:1px
    classDef data fill:#dda0dd,stroke:#333,stroke-width:1px
    classDef external fill:#87ceeb,stroke:#333,stroke-width:1px
```
