# barrier15300/cxxgametemplate architecture

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

- Interactive diagram: https://gitdiagram.com/barrier15300/cxxgametemplate
- Repository: https://github.com/barrier15300/cxxgametemplate

## Overview

##### Key System Components
- Application Entry & Core Engine:
- The main entry point (Source/Main.cpp and Source/EntryPoint.cpp) and the central game loop (evident in Game/GameMain.cpp) form the core.
- Scene Management:
- The project supports “シーン分け” (scene separation) as seen by the dedicated Scenes folder (Source/Game/Scenes) and template-based scene objects. This module controls transitions between different states or levels.
- Configuration Management:
- Use of JSON files through the Storage::Data system (as detailed in the README) indicates a subsystem dedicated to auto-generating and editing configurations.
- DxLib Wrapper Subsystem:
- Under Source/Library/Local/DxLib_wrapper there is a comprehensive wrapper around DxLib functionality. This wrapper is subdivided into:
- Media modules (GraphData, SoundData, ScreenData, FontData, etc.)
- Input modules (Keyboard, Mouse, InputState, etc.)
- Geometry and Helper modules (e.g., Geometry classes for Square, Triangle, Vertex, and helper classes for managing DXHandles).
- System and Utility Components:
- Timer, Window, and SoundDevice classes (under the “システム” section) indicate utility and system-level support.
- External Libraries:
- SDL3 serves as an external multimedia library, as found in the SDL3 directory. Its component files, CMake configuration, header files, and libraries (organized by platform) should be noted as external dependencies used by the engine.

##### Depicting Relationships and Data Flow
- A Game Core or Engine Core block that directs the flow of execution:
- It calls the Scene Manager to switch or update scenes.
- The Scene Manager interacts with:
- The Rendering/Graphics module (using the DxLib wrappers for Graph and Media components)
- The Input module (which processes keyboard/mouse events via DxLib’s input wrappers)
- The Configuration Manager that loads and saves game state via JSON.
- The DxLib Wrapper block should be illustrated as an abstraction layer that encapsulates low-level DirectX or DxLib interactions. This block is further subdivided into:
- Media (Graph, Sound, Screen, Font …)
- Input (Keyboard, Mouse, etc.)
- Geometry (Square, Triangle, Vertex data)
- System utilities (Timer, Window, SoundDevice)

##### Architectural Patterns, Component Design, and Important Principles
- Modularity and separation of concerns:
- The project is clearly organized by subsystem (scene, configuration, media, input, etc.), so group them as separate components.
- Use abstraction (wrapper pattern) for DxLib functionality. This encapsulates lower-level library calls while providing a cleaner interface for game-engine code.
- Use of template parameters in the scene system to allow flexible scene configuration.
- The configuration system leverages a “construct-if-not-found” pattern, where JSON files are loaded or generated as needed.

##### As Many Components as Possible
- Don’t hesitate to break down further internal structures:
- Annotations that mention “Wip” (work in progress) for components that are not fully implemented, as per the README comments.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Application Layer
    subgraph "Application Core"
        AppMain["\"Main Entry\""]:::core
        EntryPt["\"EntryPoint\""]:::core
        GameLoop["\"Game Loop\""]:::core
    end

    %% Engine Core
    EngineCore["\"Game Engine Core\""]:::core

    %% Subsystems
    SceneMgr["\"Scene Manager\""]:::subsystem
    JsonMgr["\"JSON Config Manager\""]:::subsystem
    DxLibWrapper["\"DxLib Wrapper\""]:::wrapper

    %% DxLib Wrapper Modules
    subgraph "DxLib Modules"
        Media["\"Media\""]:::wrapper
        Input["\"Input\""]:::wrapper
        Geometry["\"Geometry\""]:::wrapper
        Helper["\"Helper\""]:::wrapper
        Value["\"Value Types\""]:::wrapper
        Sys["\"System Utilities\""]:::wrapper
    end

    %% External Library
    SDL3["\"SDL3 External\""]:::external

    %% Connections from Application Core to Game Engine Core
    AppMain --> EngineCore
    EntryPt --> EngineCore
    GameLoop --> EngineCore

    %% Connections from Engine Core to Subsystems
    EngineCore -->|"initializes"| SceneMgr
    EngineCore -->|"loads config"| JsonMgr
    EngineCore -->|"renders/plays/input"| DxLibWrapper

    %% Connections within DxLib Wrapper: overall wrapper invokes sub-modules
    DxLibWrapper --> Media
    DxLibWrapper --> Input
    DxLibWrapper --> Geometry
    DxLibWrapper --> Helper
    DxLibWrapper --> Value
    DxLibWrapper --> Sys

    %% DxLib Wrapper depends on external SDL3
    DxLibWrapper -->|"integrates"| SDL3

    %% Styles
    classDef core fill:#ffe6e6,stroke:#cc0000,stroke-width:2px;
    classDef subsystem fill:#e6ffe6,stroke:#009900,stroke-width:2px;
    classDef wrapper fill:#e6f7ff,stroke:#0055cc,stroke-width:2px;
    classDef external fill:#fff2e6,stroke:#cc6600,stroke-width:2px;

    %% Click Events for Application Core
    click AppMain "https://github.com/barrier15300/cxxgametemplate/blob/master/Source/Main.cpp"
    click EntryPt "https://github.com/barrier15300/cxxgametemplate/blob/master/Source/EntryPoint.cpp"
    click GameLoop "https://github.com/barrier15300/cxxgametemplate/blob/master/Source/Game/GameMain.cpp"

    %% Click Events for Scene Management
    click SceneMgr "https://github.com/barrier15300/cxxgametemplate/tree/master/Source/Game/Scenes"

    %% Click Event for Configuration Manager
    click JsonMgr "https://github.com/barrier15300/cxxgametemplate/blob/master/Source/Library/Local/DxLib_wrapper/Helper/JsonHelper.h"

    %% Click Events for DxLib Wrapper Modules
    click Media "https://github.com/barrier15300/cxxgametemplate/tree/master/Source/Library/Local/DxLib_wrapper/Media"
    click Input "https://github.com/barrier15300/cxxgametemplate/tree/master/Source/Library/Local/DxLib_wrapper/Input"
    click Geometry "https://github.com/barrier15300/cxxgametemplate/tree/master/Source/Library/Local/DxLib_wrapper/Geometry"
    click Helper "https://github.com/barrier15300/cxxgametemplate/tree/master/Source/Library/Local/DxLib_wrapper/Helper"
    click Value "https://github.com/barrier15300/cxxgametemplate/tree/master/Source/Library/Local/DxLib_wrapper/Value"
    click Sys "https://github.com/barrier15300/cxxgametemplate/tree/master/Source/Library/Local/DxLib_wrapper/System"

    %% Click Event for External Library
    click SDL3 "https://github.com/barrier15300/cxxgametemplate/tree/master/SDL3"
```
