# zanark/asteroid-excursion architecture

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

- Interactive diagram: https://gitdiagram.com/zanark/asteroid-excursion
- Repository: https://github.com/zanark/asteroid-excursion

## Overview

##### Project Type and Purpose
- The project is a Unity game.
- Its primary purpose is to deliver an arcade-style gameplay experience where the player navigates through moving obstacles (asteroids) and may possibly have multiple game states (menus, levels, preloading).

##### Analyzing the File Structure
- The main project is housed under the “src/Asteroid Excursion” directory.
- Key directories include:
- Assets: Contains subdirectories for Art, Scenes, Scripts, TextMesh Pro resources, Materials, and more.
- ProjectSettings and Packages: Indicate Unity’s configurations and dependencies.
- Within Assets/Scripts you see game-related scripts such as SpaceShipMovement.cs, FollowSpaceShip.cs, MenuLoader.cs, Preloader.cs, SaveManager.cs, and SaveState.cs. These scripts likely handle game logic, player controls, scene transitions, and saving game state.
- The Scenes folder holds multiple Unity scene files like Level01.unity, MainMenu.unity, and Preloader.unity, suggesting a structured flow from game startup to menu to gameplay.
- A large number of assets related to TextMesh Pro indicate that text rendering and user interface are significant aspects of the game.

##### High-Level Architecture and Components
a. Unity Engine Core:
- Represents the underlying game engine runtime.
- Responsible for rendering, physics, audio, and general game loop management.
b. Scenes / Game Flow:
- Preloader Scene – Loads initial assets and settings.
- Main Menu Scene – Manages navigation through game menus.
- Game Level Scene(s) (e.g., Level01, SampleScene) – The core gameplay where the player navigates through asteroids.
c. Game Logic / Scripts:
- Input & Control: Scripts like SpaceShipMovement.cs and FollowSpaceShip.cs manage player input and ship movement.
- UI Management: Scripts such as MenuLoader.cs manage transitions and interface elements.
- State Management: SaveManager.cs and SaveState.cs handle game saves and persistence.
- Helper Utilities: Helper.cs likely provides common utility functions.
d. Art and Assets:
- Art assets, materials, animations, and text resources that are integrated into the scenes.
- TextMesh Pro: Manages high-quality text rendering and UI overlays.
e. External Services/Frameworks:
- Unity’s internal systems (physics engine, rendering engine, input system, etc.)
- Packages (as seen in the Packages directory) like code coverage tools and TextMesh Pro, which provide additional UI and debugging functionality.

a. Main Components:
– Game Scenes/States:
- Preloader
- Main Menu
- Gameplay Levels (Level01, SampleScene, etc.)
– Script Modules / Game Logic:
- Input Control (SpaceShipMovement, FollowSpaceShip)
- UI/Scene Management (MenuLoader, Preloader)
- Game State Management (SaveManager, SaveState)
– Asset Libraries:
- Art Assets, Materials, and TextMesh Pro resources

b. Interactions and Data Flow:
– Connect game logic components such that input controllers feed data to gameplay systems (e.g., SpaceShipMovement influencing player controls) and UI modules that trigger scene transitions.
– Show how assets (art, scripts, fonts) integrate into the scenes and are rendered via Unity and TextMesh Pro.

c. Architectural Patterns and Principles:
– Separation of Concerns: Different scripts handle separate responsibilities (movement, UI, saving).
– Component-based Design: Emphasize how Unity utilizes components attached to game objects (as indicated by numerous “.cs” scripts applied to different game objects).

d. Relevant Technologies and Frameworks:
– Unity Game Engine: For rendering, physics, and game loop.
– C#: For scripting game mechanics.
– TextMesh Pro: For advanced text rendering in the UI.
– Other Unity packages: Notably the test and coverage tools evident in ProjectSettings.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Runtime Engine"
        UE["Unity Engine Core"]:::engine
    end

    subgraph "Game Flow"
        PLS["Preloader Scene"]:::scene
        MMS["Main Menu Scene"]:::scene
        subgraph "Gameplay Levels"
            L01["Level01 Scene"]:::scene
            SS["SampleScene"]:::scene
        end
    end

    subgraph "Game Logic"
        subgraph "Input & Control"
            SSM["SpaceShipMovement"]:::gameLogic
            FSS["FollowSpaceShip"]:::gameLogic
        end
        subgraph "UI Management"
            ML["MenuLoader"]:::gameLogic
            PS["Preloader Script"]:::gameLogic
        end
        subgraph "Game State Management"
            SM["SaveManager"]:::gameLogic
            SS2["SaveState"]:::gameLogic
        end
        H["Helper Utilities: Helper"]:::gameLogic
    end

    subgraph "Assets & Resources"
        Art["Art Assets"]:::assets
        MTL["Materials"]:::assets
        TMP["TextMesh Pro Assets"]:::assets
    end

    subgraph "External Configurations"
        PSets["ProjectSettings"]:::external
        Pkgs["Packages"]:::external
    end

    %% Connections between runtime engine and scenes
    UE -->|"runs"| PLS
    PLS -->|"loads"| MMS
    MMS -->|"starts"| L01
    MMS -->|"starts"| SS

    %% UI Management triggers scene transitions
    PS -->|"triggers"| PLS
    ML -->|"triggers"| MMS

    %% Input Control influences gameplay levels
    SSM -->|"controls"| L01
    SSM -->|"controls"| SS
    FSS -->|"controls"| L01
    FSS -->|"controls"| SS

    %% Game State Management operations within gameplay
    SM -->|"saves"| L01
    SM -->|"saves"| SS
    SS2 -->|"saves"| L01
    SS2 -->|"saves"| SS

    %% Helper utilities assist various game logic modules
    H -->|"assists"| SSM
    H -->|"assists"| FSS
    H -->|"assists"| ML
    H -->|"assists"| PS

    %% Assets integration with gameplay
    Art -->|"renders"| L01
    Art -->|"renders"| SS
    MTL -->|"appliedTo"| L01
    MTL -->|"appliedTo"| SS
    TMP -->|"rendersUI"| MMS
    TMP -->|"rendersUI"| PLS

    %% External configurations setup Unity Engine
    PSets -->|"configures"| UE
    Pkgs -->|"configures"| UE

    %% Class Definitions for styling
    classDef engine fill:#ffcccc,stroke:#990000,color:#000;
    classDef scene fill:#ccffcc,stroke:#006600,color:#000;
    classDef gameLogic fill:#ccccff,stroke:#000099,color:#000;
    classDef assets fill:#ffffcc,stroke:#999900,color:#000;
    classDef external fill:#ffd700,stroke:#cc6600,color:#000;

    %% Click Events for Scenes / Game Flow
    click PLS "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scenes/Preloader.unity"
    click MMS "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scenes/MainMenu.unity"
    click L01 "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scenes/Level01.unity"
    click SS "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scenes/SampleScene.unity"

    %% Click Events for Input & Control
    click SSM "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scripts/SpaceShipMovement.cs"
    click FSS "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scripts/FollowSpaceShip.cs"

    %% Click Events for UI Management
    click ML "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scripts/MenuLoader.cs"
    click PS "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scripts/Preloader.cs"

    %% Click Events for Game State Management
    click SM "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scripts/SaveManager.cs"
    click SS2 "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scripts/SaveState.cs"

    %% Click Event for Helper Utilities
    click H "https://github.com/zanark/asteroid-excursion/blob/main/src/Asteroid Excursion/Assets/Scripts/Helper.cs"

    %% Click Events for Art and Visual Assets
    click Art "https://github.com/zanark/asteroid-excursion/tree/main/src/Asteroid Excursion/Assets/Art"
    click MTL "https://github.com/zanark/asteroid-excursion/tree/main/src/Asteroid Excursion/Assets/Materials"
    click TMP "https://github.com/zanark/asteroid-excursion/tree/main/src/Asteroid Excursion/Assets/TextMesh Pro"

    %% Click Events for External Configurations
    click PSets "https://github.com/zanark/asteroid-excursion/tree/main/src/Asteroid Excursion/ProjectSettings"
    click Pkgs "https://github.com/zanark/asteroid-excursion/tree/main/src/Asteroid Excursion/Packages"
```
