# gaspardculis/robot-rumble-rs architecture

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

- Interactive diagram: https://gitdiagram.com/gaspardculis/robot-rumble-rs
- Repository: https://github.com/gaspardculis/robot-rumble-rs

## Overview

##### Main Components
- Main Game Loop & Entry Point: Located in src/main.rs, which ties all modules together.
- Core Systems: In src/core, you have components for background rendering, camera management, gravity & physics, and world generation. These modules are the backbone of the game’s simulation and rendering mechanics.
- Entities: In src/entities – specifically the planet and player submodules. Planets include configurations and various material shader files (found in both src/entities/planet and assets/shaders/planet), while player modules manage sprites, animations, and skins.
- Networking: Found in the src/network folder handling game inputs, synchronization (synctest), and possibly connection management for the multiplayer aspect.
- Utilities: In src/utils, which provide shared functions and helpers (math, gradients, spritesheet handling) that support game logic and rendering.
- Asset Management: The assets directory clearly organizes configuration files (in RON format), shader code (for background and planet visuals), and skins data.

##### Relationships and Interactions
- The Main Game Loop calls into the Core Systems to update game physics, manage the camera, and generate/update the world.
- The Core interacts with the Entities subsystem to update state and render the game world (e.g., player movement, planet physics).
- The Entities (players and planets) use data defined in the asset configurations (shader files and config files) to render their appearance and behavior.
- The Networking module provides data flow between connected clients, feeding into the game loop and updating the game state based on remote player inputs.
- Utilities support several components by providing common maths, gradient computations, and spritesheet handling.

##### Architectural Patterns and Technologies
- Modular Design: The separation into core, entities, network, and utils shows a clear modular architecture. This modularity also extends to assets that allow flexible configurations (using RON for planet config and network settings).
- Separation of Concerns: Rendering, physics, world generation, and networking are clearly separated, ensuring each module can be updated or replaced independently.
- Data-Driven Design: Config files in the assets directory allow for dynamic changes in shaders, planet kinds, and skins without recompiling code.
- Multiplayer Architecture: Although details are sparse, the README notes the use of [matchbox] for multiplayer, suggesting a peer-to-peer or lightweight server-mediated networking structure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point
    GameLoop["Game Loop"]:::runtime

    %% Core Systems
    subgraph "Core Systems"
        Core_Background["Background Rendering"]:::runtime
        Core_Camera["Camera Management"]:::runtime
        Core_Gravity["Gravity & Physics"]:::runtime
        Core_Physics["Physics"]:::runtime
        Core_Worldgen["World Generation"]:::runtime
    end

    %% Entity Systems
    subgraph "Entity Systems"
        subgraph "Player Subsystem"
            Player_Mod["Player Module"]:::runtime
            Player_Animation["Player Animation"]:::runtime
            Player_Skin["Player Skin"]:::runtime
        end
        subgraph "Planet Subsystem"
            Planet_Mod["Planet Module"]:::runtime
            Planet_Config["Planet Configuration"]:::runtime
            subgraph "Planet Materials"
                PM_Clouds["Clouds Material"]:::runtime
                PM_Common["Common Material"]:::runtime
                PM_Craters["Craters Material"]:::runtime
                PM_Dry["Dry Terrain Material"]:::runtime
                PM_Gas["Gas Layers Material"]:::runtime
                PM_Lakes["Lakes Material"]:::runtime
                PM_Landmasses["Landmasses Material"]:::runtime
                PM_Ring["Ring Material"]:::runtime
                PM_Under["Under Material"]:::runtime
            end
        end
    end

    %% Networking
    subgraph "Networking"
        Network_Mod["Network Module"]:::network
        Network_Inputs["Network Inputs"]:::network
        Network_Synctest["Network Synctest"]:::network
    end

    %% Utilities
    subgraph "Utilities"
        Util_Math["Math Utility"]:::utils
        Util_Gradient["Gradient Utility"]:::utils
        Util_Spritesheet["Spritesheet Utility"]:::utils
    end

    %% Asset Management
    subgraph "Asset Management"
        Assets_Config["Configurations"]:::assets
        Assets_BackShader["Background Shaders"]:::assets
        Assets_PlanetShader["Planet Shaders"]:::assets
        Assets_Skins["Skins"]:::assets
    end

    %% Connections from Entry Point to Core, Entities, and Networking
    GameLoop -->|"calls"| Core_Background
    GameLoop -->|"calls"| Core_Camera
    GameLoop -->|"calls"| Core_Gravity
    GameLoop -->|"calls"| Core_Physics
    GameLoop -->|"calls"| Core_Worldgen
    GameLoop -->|"updates"| Player_Mod
    GameLoop -->|"updates"| Planet_Mod
    GameLoop -->|"receives"| Network_Mod

    %% Core Systems interactions
    Core_Background -->|"renders"| Assets_BackShader
    Core_Camera -->|"adjusts"| Player_Mod
    Core_Gravity -->|"applies"| Planet_Config
    Core_Physics -->|"simulates"| Player_Mod
    Core_Worldgen -->|"generates"| Planet_Config

    %% Entity Systems interactions
    Player_Mod -->|"drives"| Player_Animation
    Player_Mod -->|"applies"| Player_Skin

    Planet_Mod -->|"uses"| Planet_Config
    Planet_Mod -->|"renders"| PM_Clouds
    Planet_Mod -->|"renders"| PM_Common
    Planet_Mod -->|"renders"| PM_Craters
    Planet_Mod -->|"renders"| PM_Dry
    Planet_Mod -->|"renders"| PM_Gas
    Planet_Mod -->|"renders"| PM_Lakes
    Planet_Mod -->|"renders"| PM_Landmasses
    Planet_Mod -->|"renders"| PM_Ring
    Planet_Mod -->|"renders"| PM_Under

    %% Networking interactions
    Network_Mod -->|"synchronizes"| GameLoop
    Network_Inputs -->|"feeds"| Network_Mod
    Network_Synctest -->|"tests"| Network_Mod

    %% Utilities supporting various modules
    Util_Math -->|"supports"| Core_Gravity
    Util_Gradient -->|"supports"| Assets_BackShader
    Util_Spritesheet -->|"supports"| Player_Animation

    %% Asset Management connections
    Assets_Config -->|"configures"| Planet_Config
    Assets_PlanetShader -->|"provides"| PM_Clouds
    Assets_PlanetShader -->|"provides"| PM_Common
    Assets_PlanetShader -->|"provides"| PM_Craters
    Assets_PlanetShader -->|"provides"| PM_Dry
    Assets_PlanetShader -->|"provides"| PM_Gas
    Assets_PlanetShader -->|"provides"| PM_Lakes
    Assets_PlanetShader -->|"provides"| PM_Landmasses
    Assets_PlanetShader -->|"provides"| PM_Ring
    Assets_PlanetShader -->|"provides"| PM_Under
    Assets_BackShader -->|"usedby"| Core_Background
    Assets_Skins -->|"appliedto"| Player_Skin

    %% Click Events
    click GameLoop "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/main.rs"
    click Core_Background "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/core/background.rs"
    click Core_Camera "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/core/camera.rs"
    click Core_Gravity "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/core/gravity.rs"
    click Core_Physics "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/core/physics.rs"
    click Core_Worldgen "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/core/worldgen.rs"
    click Player_Mod "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/player/mod.rs"
    click Player_Animation "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/player/animation.rs"
    click Player_Skin "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/player/skin.rs"
    click Planet_Mod "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/mod.rs"
    click Planet_Config "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/config.rs"
    click PM_Clouds "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/clouds.rs"
    click PM_Common "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/common.rs"
    click PM_Craters "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/craters.rs"
    click PM_Dry "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/dry_terrain.rs"
    click PM_Gas "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/gas_layers.rs"
    click PM_Lakes "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/lakes.rs"
    click PM_Landmasses "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/landmasses.rs"
    click PM_Ring "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/ring.rs"
    click PM_Under "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/entities/planet/materials/under.rs"
    click Network_Mod "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/network/mod.rs"
    click Network_Inputs "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/network/inputs.rs"
    click Network_Synctest "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/network/synctest.rs"
    click Util_Math "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/utils/math.rs"
    click Util_Gradient "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/utils/gradient.rs"
    click Util_Spritesheet "https://github.com/gaspardculis/robot-rumble-rs/blob/main/src/utils/spritesheet.rs"
    click Assets_Config "https://github.com/gaspardculis/robot-rumble-rs/tree/main/assets/config"
    click Assets_BackShader "https://github.com/gaspardculis/robot-rumble-rs/tree/main/assets/shaders/background"
    click Assets_PlanetShader "https://github.com/gaspardculis/robot-rumble-rs/tree/main/assets/shaders/planet"
    click Assets_Skins "https://github.com/gaspardculis/robot-rumble-rs/tree/main/assets/skins"

    %% Styles
    classDef runtime fill:#E6F7FF,stroke:#1890FF,stroke-width:2px;
    classDef assets fill:#FFF1F0,stroke:#FF4D4F,stroke-width:2px;
    classDef utils fill:#F6FFED,stroke:#52C41A,stroke-width:2px;
    classDef network fill:#FFFBE6,stroke:#FAAD14,stroke-width:2px;
```
