# creusator/projet-minesmash architecture

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

- Interactive diagram: https://gitdiagram.com/creusator/projet-minesmash
- Repository: https://github.com/creusator/projet-minesmash

## Overview

##### Game Engine
- **Game.py:** Main execution loop.
- **Variables_Globales.py:** Configuration and global variables.

##### Asset Management
- **Asset Directory:** Images, sprites, and palettes.
- **Piskel Folder:** Sprite animations and interfaces.

##### Gameplay Mechanics
- **Blocs.py:** Block creation and grid management.
- **Personnage.py:** Player character management.
- **cycle_jour_nuit.py:** Day-night cycle management.

##### User Interface
- **Interface.py:** Inventory, health bars, and other UI elements.

##### Save/Load System
- **Save Directory:** Managing saved game states.

##### Utility Components
- **Item.py:** Item management and interactions.

##### b. Relationships and Interactions

- **Game Engine** interacts with **Asset Management** to load assets.
- **Game Engine** orchestrates **Gameplay Mechanics** and **User Interface**.
- **Gameplay Mechanics** (e.g., `Blocs`, `Personnage`) rely on **Variables_Globales** for configurations.
- **User Interface** displays data managed by **Gameplay Mechanics**.
- **Save/Load System** interacts with **Gameplay Mechanics** to persist and retrieve game states.
- **Utility Components** support **Gameplay Mechanics** by managing items and their interactions.

##### c. Architectural Patterns and Design Principles

- **Modular Design:** Each script handles a specific aspect of the game, promoting maintainability and scalability.
- **Object-Oriented Programming (OOP):** Utilization of classes and inheritance (`Bloc`, `Solide`, `Liquide`, `Personnage`) for structured code.
- **Separation of Concerns:** Clear division between game logic, asset management, and user interface.
- **MVC Pattern:** Implicit separation where models (game data), views (UI), and controllers (game loop) interact cohesively.

##### d. Relevant Technologies, Frameworks, or Libraries

- **Python 3.13:** Core programming language.
- **Pygame 2.6:** Library for game development, handling rendering, input, and more.
- **JSON:** Data format used in the Save system for serialization.

##### Elements

- **Clear Labels for Each Component:**
- Name each component (e.g., Game Engine, Asset Manager, Player Controller) clearly.

##### Top Layer: Game Engine
- **Game.py**
- **Variables_Globales.py**

##### Middle Layer: Core Components
- **Blocs.py** (connected to Game Engine)
- **Personnage.py** (connected to Game Engine)
- **cycle_jour_nuit.py** (connected to Game Engine)

##### Side Layers: Supporting Systems
- **Interface.py** (connected to Game Engine and Core Components)
- **Item.py** (connected to Core Components)

##### Bottom Layer: Asset and Save Systems
- **Asset Management** (linked to Game Engine and Core Components)
- **Save Directory** (linked to Core Components)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    GameEngine["Game Engine"]:::engine
    VariablesGlobals["Variables_Globales.py"]:::engine

    %% Subgraphs and modules
    subgraph "Asset Management"
        AssetManagement["Asset Management"]:::asset
        imageDir["Asset/image/"]:::asset
        piskelDir["Asset/piskel/"]:::asset
    end

    subgraph "Gameplay Mechanics"
        Blocs["Blocs.py"]:::gameplay
        Personnage["Personnage.py"]:::gameplay
        cycleJourNuit["cycle_jour_nuit.py"]:::gameplay
    end

    subgraph "User Interface"
        Interface["Interface.py"]:::ui
    end

    subgraph "Save/Load System"
        SaveLoadSystem["Save/Load System"]:::save
        saveDir["Save/"]:::save
        chunk1["chunk1.json"]:::save
        inventaire["inventaire.json"]:::save
    end

    subgraph "Utility Components"
        Item["Item.py"]:::utility
    end

    %% Connections
    GameEngine --> AssetManagement
    GameEngine --> Blocs
    GameEngine --> Personnage
    GameEngine --> cycleJourNuit
    GameEngine --> Interface
    GameEngine --> SaveLoadSystem

    Blocs --> VariablesGlobals
    Personnage --> VariablesGlobals
    cycleJourNuit --> VariablesGlobals

    Interface --> Blocs
    Interface --> Personnage

    SaveLoadSystem --> Blocs
    SaveLoadSystem --> Personnage

    Item --> Blocs
    Item --> Personnage

    %% Click Events
    click GameEngine "https://github.com/creusator/projet-minesmash/blob/main/Scripts/Game.py"
    click VariablesGlobals "https://github.com/creusator/projet-minesmash/blob/main/Scripts/Variables_Globales.py"
    click AssetManagement "https://github.com/creusator/projet-minesmash/tree/main/Asset/"
    click imageDir "https://github.com/creusator/projet-minesmash/tree/main/Asset/image/"
    click piskelDir "https://github.com/creusator/projet-minesmash/tree/main/Asset/piskel/"
    click Blocs "https://github.com/creusator/projet-minesmash/blob/main/Scripts/Blocs.py"
    click Personnage "https://github.com/creusator/projet-minesmash/blob/main/Scripts/Personnage.py"
    click cycleJourNuit "https://github.com/creusator/projet-minesmash/blob/main/Scripts/cycle_jour_nuit.py"
    click Interface "https://github.com/creusator/projet-minesmash/blob/main/Scripts/Interface.py"
    click SaveLoadSystem "https://github.com/creusator/projet-minesmash/tree/main/Save/"
    click saveDir "https://github.com/creusator/projet-minesmash/tree/main/Save/"
    click chunk1 "https://github.com/creusator/projet-minesmash/blob/main/Save/monde-test/chunk1.json"
    click inventaire "https://github.com/creusator/projet-minesmash/blob/main/Save/monde-test/inventaire.json"
    click Item "https://github.com/creusator/projet-minesmash/blob/main/Scripts/Item.py"

    %% Styles
    classDef engine fill:#f9f,stroke:#333,stroke-width:2px;
    classDef asset fill:#bbf,stroke:#333,stroke-width:2px;
    classDef gameplay fill:#bfb,stroke:#333,stroke-width:2px;
    classDef ui fill:#fbf,stroke:#333,stroke-width:2px;
    classDef save fill:#ffb,stroke:#333,stroke-width:2px;
    classDef utility fill:#fbb,stroke:#333,stroke-width:2px;
    class GameEngine,VariablesGlobals engine
    class AssetManagement,imageDir,piskelDir asset
    class Blocs,Personnage,cycleJourNuit gameplay
    class Interface ui
    class SaveLoadSystem,saveDir,chunk1,inventaire save
    class Item utility
```
