# rbardet/cub3d-de-la-commu architecture

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

- Interactive diagram: https://gitdiagram.com/rbardet/cub3d-de-la-commu
- Repository: https://github.com/rbardet/cub3d-de-la-commu

## Overview

##### Key Components
- Main Entry Point: Include the “srcs/main.c” which bootstraps the application.
- Parsing Module: Represented by the “srcs/parsing” directory. This module handles loading and validating map files (from the “maps” directory), setting up configurations such as textures (e.g., PNG loading) and RGB values.
- Graphics and Raycasting Engine: Captured in “srcs/raycasting”. This is the core of the rendering process that uses raycasting for 3D visualization. It includes calculation of rays, intersection tests, drawing routines, etc.
- Movement Module: In “srcs/movement” which processes player input and rotation, updating the player’s position within the world.
- Bonus Features: Modules like “srcs/bonus” contain additional elements like animated sprites, doors, and a minimap, which extend the base engine.
- Utility Functions: Found under “srcs/utils” which support debugging, structural management, and other common operations.
- Graphical Assets: The “graphic” directory contains media such as animations, videos (e.g., “john.mp4”), and texture packs that support the visual aspects of the engine.
- Configuration and Map Files: The “maps” directory holds different .cub files with various scenarios (valid, invalid, different design types) showcasing how the game levels are defined.

##### Relationships and Data Flow
- The Main Module initializes the application and calls the Parsing Module to load game configuration and level data.
- The Raycasting Module uses the provided configuration to render the 3D environment. It interacts with the Movement Module to update the player’s position so that scenes can be recalculated and redrawn in real time.
- The Bonus Modules integrate with the primary game loop to manage extended gameplay features (doors, animated sprites, minimap) and enhance the overall functionality.
- Utility modules are invoked by the other components for debugging output and for structured management of runtime data.

##### Architectural Patterns and Design Choices
- The structure is modular, clearly separating concerns such as input parsing, rendering (raycasting), and movement.
- There is likely a game loop that continuously updates the player’s state (movement) and renders the scene (raycasting).
- The project seems to follow a procedural design with separate functional units (or “modules”) and single-responsibility functions for tasks like parsing, drawing, and movement handling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Modules
    subgraph "Core Modules"
        MAIN["Main Entry Point"]:::module
        PARSING["Parsing Module"]:::module
        RAYCAST["Raycasting Engine"]:::module
        MOVEMENT["Movement Module"]:::module
        BONUS["Bonus Features"]:::module
        UTILS["Utility Functions"]:::module
    end

    %% External Resources
    subgraph "External Resources"
        MAPS["Map Files (.cub)"]:::external
        GRAPHIC["Graphic Assets"]:::external
    end

    %% Relationships and Data Flow
    MAIN -->|"initializes"| PARSING
    PARSING -->|"loads_map"| MAPS
    PARSING -->|"loads_textures"| GRAPHIC
    PARSING -->|"passes_config_to"| RAYCAST
    RAYCAST <-->|"gameLoop"| MOVEMENT
    BONUS -->|"enhances_rendering"| RAYCAST
    BONUS -->|"enhances_input"| MOVEMENT
    UTILS -->|"supports"| MAIN
    UTILS -->|"supports"| PARSING
    UTILS -->|"supports"| RAYCAST
    UTILS -->|"supports"| MOVEMENT
    UTILS -->|"supports"| BONUS

    %% Additional Game Loop Cycle Representation
    MOVEMENT -->|"updates"| RAYCAST
    RAYCAST -->|"renders"| MOVEMENT

    %% Click Events for Component Mappings
    click MAIN "https://github.com/rbardet/cub3d-de-la-commu/blob/main/srcs/main.c"
    click PARSING "https://github.com/rbardet/cub3d-de-la-commu/tree/main/srcs/parsing"
    click RAYCAST "https://github.com/rbardet/cub3d-de-la-commu/tree/main/srcs/raycasting"
    click MOVEMENT "https://github.com/rbardet/cub3d-de-la-commu/tree/main/srcs/movement"
    click BONUS "https://github.com/rbardet/cub3d-de-la-commu/tree/main/srcs/bonus"
    click UTILS "https://github.com/rbardet/cub3d-de-la-commu/tree/main/srcs/utils"
    click GRAPHIC "https://github.com/rbardet/cub3d-de-la-commu/tree/main/graphic"
    click MAPS "https://github.com/rbardet/cub3d-de-la-commu/tree/main/maps"

    %% Styles
    classDef module fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#333,stroke-width:2px;
```
