# 777chara777/myengine architecture

> Architecture diagram of the GitHub repository 777chara777/myengine, 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/777chara777/myengine
- Repository: https://github.com/777chara777/myengine

## Overview

##### Main Components
- Engine Core (MyEngine/Engine.py): The primary entry point and base for initializing and running the game.
- Graphics/Rendering Module (_render): Responsible for drawing, including integration with a C++ “dll” component (project.cpp) for potential performance-critical rendering tasks.
- Math Module (_math): Contains vector, matrix, and geometric computations, essential for 2D/3D object manipulation and camera transformations.
- Physics Module (_physics): Supplies physical computations such as collision detection and rigid body dynamics (e.g., HitBox, RigidBody).
- I/O and Input Handling (_io): Manages user input (Keyboard, Mouse) and also handles sound and screen output.
- Artificial Intelligence (_ai): Though details are minimal here, it’s likely meant for handling game AI or logic.
- Networking (_network): Provides networking capabilities with client/server modules and additional network extensions under subdirectories.
- Resource and Utility Modules (_utils): Contains a BaseModule (coming from external BaseModule repository), resource management, scripting support, and timer utilities.
- World Management (_world): Responsible for loading objects (bodies) into the scene, managing positions, and standard game object tags.
- Additional Modules: There are also directories like _founts (potentially for fonts or similar resources) and _object which likely represents how game objects are encapsulated.

##### Relationships and Interactions
- The Engine (MyEngine/Engine.py) uses several submodules: it invokes the World to load bodies (objects from files like cube.obj), manipulates the Camera (through transformations calculated in the _math module), and delegates input functionality to the _io submodule.
- The Render module (_render) interacts with the physics (for visualizing hitboxes or collisions) and math modules.
- The Script system (demonstrated via adding scripts in the README) shows dynamic extension capability. Scripts are loaded at runtime and interact with the Engine Core to update object positions and react to input.
- There is a clear directional flow: Initialization (Engine setup) → Game Loop (on_update or update methods) → Rendering & Input Handling → External Script calls.
- The networking components hint at potential multiplayer or networked functionality where the engine might communicate with other instances, either as client or via a server.

##### Architectural Patterns and Design Principles
- Modularity: Several “_” prefixed directories indicate separate functional modules that are loosely coupled but interact through well-defined interfaces (e.g., scripts supply behavior that the Engine calls back, and resource managers support asset loading).
- Layered Architecture: The structure demonstrates a layering from low-level mathematics and IO up to high-level engine control and scripting.
- External Integration: Integration of third-party libraries (PyGame and BaseModule) is central to the engine’s operation.

##### Including Relevant Technologies and Frameworks
- Python as the core language.
- PyGame for rendering and window management.
- BaseModule, which is used for logging and error management.
- A small C++ component within the _render/dll that might be used for performance-critical rendering tasks.

##### Instructing the Principal Software Engineer to Include these Elements
- “Engine Core” (main application and game loop)
- “Rendering Module” (with its tie-in to the C++ DLL)
- “Math Module” (for vector, matrix, and triangle computations)
- “Physics Module” (including RigidBody and HitBox implementation)
- “I/O Module” (Keyboard, Mouse, Sound, Screen)
- “Networking Module” (client, server, and network extension modules)
- “Scripting System” (plug-in scripts like player_controller and test scripts)
- “World Management” (loading and managing game objects)
- “Configuration & Build Tools” (settings.yml, build commands)
- “External Libraries” (PyGame, BaseModule)
- From user inputs to I/O module, then to Engine and Scripts.
- From Engine to the Rendering, Physics, Math, and World modules.
- Between Scripting and World Management for object manipulation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global External Nodes
    ExternalLibraries["External Libraries\n(Pygame, etc.)"]:::external
    Config["Configuration & Build Tools"]:::config
    UserInput["User Input"]:::input

    %% Engine Core and Scripting
    subgraph "Engine Core Layer"
        EngineCore["Engine Core"]:::maincore
        Scripting["Scripting System"]:::module
    end

    %% Core Modules
    subgraph "Core Modules"
        Rendering["Rendering Module"]:::module
        subgraph "Rendering Details"
            RenderFile["Render.py"]:::detail
            DLL["C++ DLL Integration"]:::detail
        end

        Math["Math Module"]:::module
        subgraph "Math Details"
            Vectors["Vectors"]:::detail
            Mash["Mash"]:::detail
            Matrix["Matrix"]:::detail
            Triangle["Triangle"]:::detail
        end

        Physics["Physics Module"]:::module
        subgraph "Physics Details"
            HitBox["HitBox"]:::detail
            RigidBody["RigidBody"]:::detail
        end

        IO["I/O Module"]:::module
        subgraph "I/O Details"
            Keyboard["Keyboard"]:::detail
            Mouse["Mouse"]:::detail
            SoundController["SoundController"]:::detail
            Screen["Screen"]:::detail
        end

        AI["Artificial Intelligence"]:::module
        
        Networking["Networking Module"]:::module
        subgraph "Networking Details"
            Client["Client"]:::detail
            Server["Server"]:::detail
            Dopmodule["Dopmodule"]:::detail
        end

        Utils["Resource & Utility Modules"]:::module
        subgraph "Utils Details"
            BaseMod["BaseModule Integration"]:::detail
            ResourceManager["ResourceManager"]:::detail
            Script["Script"]:::detail
            Timer["Timer"]:::detail
        end

        World["World Management"]:::module
        ObjectEncap["Object Encapsulation"]:::module
    end

    %% Relationships
    ExternalLibraries -->|"uses"| EngineCore
    Config -->|"configures"| EngineCore
    UserInput -->|"input"| IO

    EngineCore -->|"initializes"| Rendering
    EngineCore -->|"computes"| Math
    EngineCore -->|"processes"| Physics
    EngineCore -->|"handles"| IO
    EngineCore -->|"manages"| World
    EngineCore -->|"delegates"| Scripting
    EngineCore -->|"interfaces"| Networking
    EngineCore -->|"logs_via"| Utils
    EngineCore -->|"triggers"| AI
    EngineCore -->|"utilizes"| ObjectEncap

    Scripting -->|"modifies"| World

    Math -->|"transforms"| Rendering
    Physics -->|"informs_collisions"| Rendering

    Rendering -->|"invokes"| DLL

    %% Click Events
    click EngineCore "https://github.com/777chara777/myengine/blob/main/MyEngine/Engine.py"
    click Rendering "https://github.com/777chara777/myengine/tree/main/MyEngine/_render"
    click RenderFile "https://github.com/777chara777/myengine/blob/main/MyEngine/_render/render.py"
    click DLL "https://github.com/777chara777/myengine/blob/main/MyEngine/_render/dll/project.cpp"
    click Math "https://github.com/777chara777/myengine/tree/main/MyEngine/_math"
    click Vectors "https://github.com/777chara777/myengine/blob/main/MyEngine/_math/vectors.py"
    click Mash "https://github.com/777chara777/myengine/blob/main/MyEngine/_math/mash.py"
    click Matrix "https://github.com/777chara777/myengine/blob/main/MyEngine/_math/matrix.py"
    click Triangle "https://github.com/777chara777/myengine/blob/main/MyEngine/_math/triangle.py"
    click Physics "https://github.com/777chara777/myengine/tree/main/MyEngine/_physics"
    click HitBox "https://github.com/777chara777/myengine/blob/main/MyEngine/_physics/HitBox.py"
    click RigidBody "https://github.com/777chara777/myengine/blob/main/MyEngine/_physics/RigidBody.py"
    click IO "https://github.com/777chara777/myengine/tree/main/MyEngine/_io"
    click Keyboard "https://github.com/777chara777/myengine/blob/main/MyEngine/_io/Keyboard.py"
    click Mouse "https://github.com/777chara777/myengine/blob/main/MyEngine/_io/Mouse.py"
    click SoundController "https://github.com/777chara777/myengine/blob/main/MyEngine/_io/SoundController.py"
    click Screen "https://github.com/777chara777/myengine/blob/main/MyEngine/_io/screen.py"
    click AI "https://github.com/777chara777/myengine/tree/main/MyEngine/_ai"
    click Networking "https://github.com/777chara777/myengine/tree/main/MyEngine/_network"
    click Client "https://github.com/777chara777/myengine/blob/main/MyEngine/_network/client.py"
    click Server "https://github.com/777chara777/myengine/blob/main/MyEngine/_network/server.py"
    click Dopmodule "https://github.com/777chara777/myengine/blob/main/MyEngine/_network/module/Dopmodule.py"
    click Utils "https://github.com/777chara777/myengine/tree/main/MyEngine/_utils"
    click BaseMod "https://github.com/777chara777/myengine/tree/main/MyEngine/_utils/BaseModule"
    click ResourceManager "https://github.com/777chara777/myengine/blob/main/MyEngine/_utils/ResourceManager.py"
    click Script "https://github.com/777chara777/myengine/blob/main/MyEngine/_utils/Script.py"
    click Timer "https://github.com/777chara777/myengine/blob/main/MyEngine/_utils/Timer.py"
    click World "https://github.com/777chara777/myengine/blob/main/MyEngine/_world.py"
    click ObjectEncap "https://github.com/777chara777/myengine/blob/main/MyEngine/_object.py"

    %% Styles
    classDef maincore fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef module fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef detail fill:#FFF9C4,stroke:#FBC02D,stroke-width:1px;
    classDef external fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
    classDef config fill:#D1C4E9,stroke:#5E35B1,stroke-width:2px;
    classDef input fill:#F0F4C3,stroke:#7CB342,stroke-width:2px;
```
