# luke23127006/mario-reflourished architecture

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

- Interactive diagram: https://gitdiagram.com/luke23127006/mario-reflourished
- Repository: https://github.com/luke23127006/mario-reflourished

## Overview

##### Main Components
- Core Game Loop & State Management:
- Files: main.cpp, Game.cpp, Shell.cpp, Global.cpp
- Role: Initializes the game, drives the main loop, and manages game states (e.g., Welcome, Pause, Play, VictoryScene).
- Game Modes and Scenes:
- Files: AdventureMode.cpp/h, CustomMode.cpp/h, EndlessMode.cpp/h, VictoryScene.cpp/h, Welcome.cpp/h, Play.cpp/h, Pause.cpp/h
- Role: Different game modes and scenes are almost like state objects that affect gameplay, each representing a unique part of game flow.
- Entities and Components:
- Files: Entity.cpp/h, Component.cpp/h, Enemy.cpp/h (and subclasses such as Goomba, Koopa, Bowser, etc.), Player.cpp/h, EntityFactory.cpp/h, Tile.cpp/h, TileFactory.cpp/h
- Role: These files define individual game objects and the component-based system that may be used for extending behavior. They include players, enemies, and game objects like coins, power-ups, and obstacles.
- Collision and Physics:
- Files: Collision.cpp/h, Barrier.cpp/h, EnemyBarrier.cpp/h, SpikeWall.cpp/h, Lava.cpp/h, Water.cpp/h
- Role: Manage interactions between entities and the environment, ensuring proper collision handling which is vital in a platformer.
- Resource Management:
- Files: Resources.cpp/h, ColorManager.cpp/h, Animation.cpp/h, Particle.cpp/h and the dedicated Resources folder (with textures, maps, characters, audio, and more)
- Role: Handling loading and management of game assets, ensuring that textures, audio, fonts, and other resources are properly accessed.
- User Interface (UI) and Menus:
- Files: HUD.cpp/h, Login.cpp/h, SelectCharacter.cpp/h, SelectLevel.cpp/h, Button.cpp/h, Text.cpp/h
- Role: Responsible for on-screen display elements such as score, menus, and input handling for non-gameplay user interactions.

##### Component Relationships and Interactions
- The Core Game Loop (main.cpp, Game.cpp) acts as the conductor and interacts with:
- The Game Modes/Scenes to switch between states (Welcome, Play, Pause, Victory, etc.).
- The Entity/Component system, which is updated, rendered, and checks collisions within each frame.
- The Resource Manager to supply textures, audio clips, and other assets.
- The Entity subsystem creates objects using the EntityFactory which instantiates players, enemies, and items (from numerous header and source files).
- SFML integration is central; it handles rendering (Graphics), audio playback (Sound), and input (Window/Events), making these external libraries a critical “service” in the system architecture.
- Collision and physics modules need to interact with entities, ensuring proper overlap testing and responses when entities interact with level geometry or one another.

##### Architectural Patterns & Design Principles
- Modularity & Separation of Concerns: Each game element (modes, UI, entities) is handled in its own set of files; clearly separating gameplay logic from resource management and presentation.
- Component-Based Design: The existence of a Component.cpp/h suggests that entities might use a component-based system for flexibility.
- Factory Pattern: The EntityFactory and TileFactory signal the use of design patterns to instantiate game objects dynamically.
- Event-driven or State Machine: The differing game modes and UI states imply that the game likely uses state management to transition between game scenes.

##### Technologies and Frameworks
- SFML is a key technology, as seen in the SFML directory containing headers and libraries for Audio, Graphics, System, etc.
- C++ is the language of choice, with a Visual Studio solution file provided (Mario Reflourished.sln).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Core Game Loop & State Management
    subgraph "Core Game Loop & State Management"
        A1["main.cpp"]:::engine
        A2["Game.cpp"]:::engine
        A3["Shell.cpp"]:::engine
        A4["Global.cpp"]:::engine
    end

    %% Game Modes & Scenes
    subgraph "Game Modes & Scenes"
        B1["AdventureMode.cpp/h"]:::gamemode
        B2["CustomMode.cpp/h"]:::gamemode
        B3["EndlessMode.cpp/h"]:::gamemode
        B4["VictoryScene.cpp/h"]:::gamemode
        B5["Welcome.cpp/h"]:::gamemode
        B6["Play.cpp/h"]:::gamemode
        B7["Pause.cpp/h"]:::gamemode
        B8["CustomLevel.cpp/h"]:::gamemode
    end

    %% Entities & Components
    subgraph "Entities & Components"
        C1["Entity.cpp/h"]:::entity
        C2["Component.cpp/h"]:::entity
        C3["Enemy.cpp/h"]:::entity
        C4["Goomba.cpp/h"]:::entity
        C5["Koopa.cpp/h"]:::entity
        C6["Bowser.cpp/h"]:::entity
        C7["Player.cpp/h"]:::entity
        C8["EntityFactory.cpp/h"]:::entity
        C9["Tile.cpp/h"]:::entity
        C10["TileFactory.cpp/h"]:::entity
    end

    %% Collision & Physics
    subgraph "Collision & Physics"
        D1["Collision.cpp/h"]:::collision
        D2["Barrier.cpp/h"]:::collision
        D3["EnemyBarrier.cpp/h"]:::collision
        D4["SpikeWall.cpp/h"]:::collision
        D5["Lava.cpp/h"]:::collision
        D6["Water.cpp/h"]:::collision
    end

    %% Resource Management
    subgraph "Resource Management"
        E1["Resources.cpp/h"]:::resource
        E2["Animation.cpp/h"]:::resource
        E3["Particle.cpp/h"]:::resource
        E4["ColorManager.cpp/h"]:::resource
        E5["Resources/"]:::resourceDir
    end

    %% User Interface (UI) & Menus
    subgraph "User Interface (UI) & Menus"
        F1["HUD.cpp/h"]:::ui
        F2["Login.cpp/h"]:::ui
        F3["SelectCharacter.cpp/h"]:::ui
        F4["SelectLevel.cpp/h"]:::ui
        F5["Button.cpp/h"]:::ui
        F6["Text.cpp/h"]:::ui
    end

    %% External Dependencies (SFML)
    subgraph "External Dependencies (SFML)"
        G1["SFML/"]:::external
    end

    %% Connections between major subsystems
    A1 -->|"switchState"| B1
    A1 -->|"update"| C1
    A1 -->|"loadAssets"| E1
    C1 -->|"collision"| D1
    B1 -->|"requestAssets"| E1
    F1 -->|"displayAssets"| E1
    G1 -->|"render/input"| A1
    G1 -->|"render/UI"| F1
    A1 -->|"showMenu"| F1

    %% Click Events for Core Game Loop & State Management
    click A1 "https://github.com/luke23127006/mario-reflourished/blob/master/main.cpp"
    click A2 "https://github.com/luke23127006/mario-reflourished/blob/master/Game.cpp"
    click A3 "https://github.com/luke23127006/mario-reflourished/blob/master/Shell.cpp"
    click A4 "https://github.com/luke23127006/mario-reflourished/blob/master/Global.cpp"

    %% Click Events for Game Modes & Scenes
    click B1 "https://github.com/luke23127006/mario-reflourished/tree/master/AdventureMode.cpp/h"
    click B2 "https://github.com/luke23127006/mario-reflourished/tree/master/CustomMode.cpp/h"
    click B3 "https://github.com/luke23127006/mario-reflourished/tree/master/EndlessMode.cpp/h"
    click B4 "https://github.com/luke23127006/mario-reflourished/tree/master/VictoryScene.cpp/h"
    click B5 "https://github.com/luke23127006/mario-reflourished/tree/master/Welcome.cpp/h"
    click B6 "https://github.com/luke23127006/mario-reflourished/tree/master/Play.cpp/h"
    click B7 "https://github.com/luke23127006/mario-reflourished/tree/master/Pause.cpp/h"
    click B8 "https://github.com/luke23127006/mario-reflourished/tree/master/CustomLevel.cpp/h"

    %% Click Events for Entities & Components
    click C1 "https://github.com/luke23127006/mario-reflourished/tree/master/Entity.cpp/h"
    click C2 "https://github.com/luke23127006/mario-reflourished/tree/master/Component.cpp/h"
    click C3 "https://github.com/luke23127006/mario-reflourished/tree/master/Enemy.cpp/h"
    click C4 "https://github.com/luke23127006/mario-reflourished/tree/master/Goomba.cpp/h"
    click C5 "https://github.com/luke23127006/mario-reflourished/tree/master/Koopa.cpp/h"
    click C6 "https://github.com/luke23127006/mario-reflourished/tree/master/Bowser.cpp/h"
    click C7 "https://github.com/luke23127006/mario-reflourished/tree/master/Player.cpp/h"
    click C8 "https://github.com/luke23127006/mario-reflourished/tree/master/EntityFactory.cpp/h"
    click C9 "https://github.com/luke23127006/mario-reflourished/tree/master/Tile.cpp/h"
    click C10 "https://github.com/luke23127006/mario-reflourished/tree/master/TileFactory.cpp/h"

    %% Click Events for Collision & Physics
    click D1 "https://github.com/luke23127006/mario-reflourished/tree/master/Collision.cpp/h"
    click D2 "https://github.com/luke23127006/mario-reflourished/tree/master/Barrier.cpp/h"
    click D3 "https://github.com/luke23127006/mario-reflourished/tree/master/EnemyBarrier.cpp/h"
    click D4 "https://github.com/luke23127006/mario-reflourished/tree/master/SpikeWall.cpp/h"
    click D5 "https://github.com/luke23127006/mario-reflourished/tree/master/Lava.cpp/h"
    click D6 "https://github.com/luke23127006/mario-reflourished/tree/master/Water.cpp/h"

    %% Click Events for Resource Management
    click E1 "https://github.com/luke23127006/mario-reflourished/tree/master/Resources.cpp/h"
    click E2 "https://github.com/luke23127006/mario-reflourished/tree/master/Animation.cpp/h"
    click E3 "https://github.com/luke23127006/mario-reflourished/tree/master/Particle.cpp/h"
    click E4 "https://github.com/luke23127006/mario-reflourished/tree/master/ColorManager.cpp/h"
    click E5 "https://github.com/luke23127006/mario-reflourished/tree/master/Resources/"

    %% Click Events for User Interface (UI) & Menus
    click F1 "https://github.com/luke23127006/mario-reflourished/tree/master/HUD.cpp/h"
    click F2 "https://github.com/luke23127006/mario-reflourished/tree/master/Login.cpp/h"
    click F3 "https://github.com/luke23127006/mario-reflourished/tree/master/SelectCharacter.cpp/h"
    click F4 "https://github.com/luke23127006/mario-reflourished/tree/master/SelectLevel.cpp/h"
    click F5 "https://github.com/luke23127006/mario-reflourished/tree/master/Button.cpp/h"
    click F6 "https://github.com/luke23127006/mario-reflourished/tree/master/Text.cpp/h"

    %% Click Event for External Dependencies
    click G1 "https://github.com/luke23127006/mario-reflourished/tree/master/SFML/"

    %% Styles
    classDef engine fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef gamemode fill:#f9d56e,stroke:#333,stroke-width:2px;
    classDef entity fill:#87cefa,stroke:#333,stroke-width:2px;
    classDef collision fill:#ffb6c1,stroke:#333,stroke-width:2px;
    classDef resource fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef resourceDir fill:#dda0dd,stroke:#333,stroke-width:2px;
    classDef ui fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef external fill:#ffdab9,stroke:#333,stroke-width:2px;
```
