# claudianistal/return-to-the-jungle architecture

> Architecture diagram of the GitHub repository claudianistal/return-to-the-jungle, 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/claudianistal/return-to-the-jungle
- Repository: https://github.com/claudianistal/return-to-the-jungle

## Overview

##### Project Type and Purpose
- This is a 2D platformer video game built in C++ for an academic project.
- The game uses SDL2 as its graphics, input, and audio library and includes external libraries (e.g., Chipmunk, for physics) bundled in the docs/librerias directory.
- The gameplay revolves around distinct animal characters (Mono, Elefante, Serpiente, Tucán, Capibara) navigating obstacles in city and jungle environments.

##### Main Components
A. Game Initialization & Main Loop
- Main.cpp and Game.cpp are the entry points.

B. Game Layers and Scenes
- Different layers in the game such as:
– MenuLayer (for main menu interactions)
– CharacterSelectionLayer (for picking characters)
– GameLayer (for in-game play)
– MenuFinalLayer (for end-of-game or win/lose screens)
- These should be visualized as separate, interacting modules within the overall game engine.

C. Entities and Actors
- Actors include classes such as Actor, Enemy, Player, and various specialized entities (e.g., Capibara, Mono, Elefante, Serpiente, Tucan).
- Animation (Animation.cpp/.h) to handle sprite animations, and Audio for sound effects/music.
- Use “Entity Manager” or “Game Objects” module to denote the management of these actors.

D. Tile and Level Design System
- A set of classes such as Tile, BoxTile, WaterTile, TunnelTile, etc., build the 2D tile environment for the levels.
- That levels are defined by text files inside the ‘res’ directory – creating a map parser/level loader component.

E. External Libraries and Resource Management
- SDL2 is the core library for handling graphics, input, and audio.
- Chipmunk (from the docs/librerias/include/chipmunk folder) is likely used for physics/collision handling.
- An “External Dependencies” module that interacts with both the game engine and subsystems like rendering and physics.
- A “Resource Manager” component should also be noted as responsible for loading assets (sprites, audio, level layouts) from the ‘res’ folder.

##### Relationships & Interactions
- Associations between the Game Engine and the Entities sub-system (for updating positions, handling animations and audio).
- Data flow from the Resource Manager to the Entities (for assets) and Level Loader.
- Dependencies where the SDL2 and Chipmunk libraries provide lower-level services (graphics rendering, event handling, physics simulation).

##### Architectural Patterns & Principles
- Modular design by isolating layers and components; this separation aids maintenance and potential future expansion.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Engine
    GE["Game Engine/Main Loop"]:::core

    %% Game Layers
    subgraph "Game Layers"
        ML["Menu Layer"]:::layer
        CSL["Character Selection Layer"]:::layer
        GL["Game Layer"]:::layer
        MFL["Final/Menu End Layer"]:::layer
    end

    %% Entities & Actors
    subgraph "Entities & Actors"
        EM["Entity Manager"]:::entity
        AB["Actor (Base)"]:::entity
        Mono["Mono"]:::entity
        Elefante["Elefante"]:::entity
        Serpiente["Serpiente"]:::entity
        Tucan["Tucan"]:::entity
        Capibara["Capibara"]:::entity
        Enemy["Enemy"]:::entity
        Player["Player"]:::entity
    end

    %% Animation & Audio System
    AA["Animation & Audio Systems"]:::subsystem

    %% Tile & Level System
    subgraph "Tile & Level System"
        Tile["Tile"]:::subsystem
        BoxTile["BoxTile"]:::subsystem
        WaterTile["WaterTile"]:::subsystem
        TunnelTile["TunnelTile"]:::subsystem
        LevelFiles["Level Files"]:::subsystem
    end

    %% Resource Manager
    RM["Resource Manager"]:::subsystem

    %% External Dependencies
    subgraph "External Dependencies"
        SDL["SDL2 - Rendering & Input"]:::external
        CHIP["Chipmunk - Physics Engine"]:::external
    end

    %% Relationships
    GE -->|"controls"| ML
    GE -->|"controls"| CSL
    GE -->|"controls"| GL
    GE -->|"controls"| MFL

    GE -->|"updates"| EM
    GE -->|"updates"| AA

    CSL -->|"characterSelect"| GL

    RM -->|"suppliesAssets"| EM
    RM -->|"loads"| Tile
    RM -->|"assetsFor"| AA
    RM -->|"assetsFor"| LevelFiles

    Tile -->|"defines"| GL

    EM -->|"manages"| AB
    AB -->|"extends"| Mono
    AB -->|"extends"| Elefante
    AB -->|"extends"| Serpiente
    AB -->|"extends"| Tucan
    AB -->|"extends"| Capibara
    EM -->|"includes"| Enemy
    EM -->|"includes"| Player

    SDL -->|"providesService"| GE
    CHIP -->|"providesPhysics"| GE

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef layer fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef entity fill:#FFFFE0,stroke:#000,stroke-width:2px;
    classDef subsystem fill:#F08080,stroke:#000,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#000,stroke-width:2px;

    %% Click Events
    click GE "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Main.cpp"
    click ML "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/MenuLayer.cpp"
    click CSL "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/CharacterSelectionLayer.cpp"
    click GL "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/GameLayer.cpp"
    click MFL "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/MenuFinalLayer.cpp"
    click AB "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Actor.cpp"
    click Mono "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Mono.cpp"
    click Elefante "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Elefante.cpp"
    click Serpiente "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Serpiente.cpp"
    click Tucan "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Tucan.cpp"
    click Capibara "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Capibara.cpp"
    click Enemy "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Enemy.cpp"
    click Player "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Player.cpp"
    click AA "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Animation.cpp"
    click Tile "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/Tile.cpp"
    click BoxTile "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/BoxTile.cpp"
    click WaterTile "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/WaterTile.cpp"
    click TunnelTile "https://github.com/claudianistal/return-to-the-jungle/blob/master/VideojuegoPlataformasAnimales/TunnelTile.cpp"
    click LevelFiles "https://github.com/claudianistal/return-to-the-jungle/tree/master/VideojuegoPlataformasAnimales/res"
    click RM "https://github.com/claudianistal/return-to-the-jungle/tree/master/VideojuegoPlataformasAnimales/res"
    click SDL "https://github.com/claudianistal/return-to-the-jungle/tree/master/docs/librerias/include/"
    click CHIP "https://github.com/claudianistal/return-to-the-jungle/tree/master/docs/librerias/include/chipmunk"
```
