# addamc/jogo_allegro architecture

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

- Interactive diagram: https://gitdiagram.com/addamc/jogo_allegro
- Repository: https://github.com/addamc/jogo_allegro

## Overview

##### Project type and purpose
- From the README and file tree, this is a small 2D game written in C++ using the Allegro library (version 4.x).
- It’s a learning project from a second-year college course, focusing on sprite-based rendering, basic game loop, collision, input handling, and simple entity management.

##### File structure
- Top level:
- main.cpp – the entry point, contains the game initialization, main loop, and shutdown logic.
- Headers (*.h): classes representing game entities and subsystems (Personagem (player), Inimigo (enemy), Ground, Escada (ladder), Shooting, LevelManager, Menu, global definitions).
- Sprites/ – all bitmap assets for backgrounds, characters, UI elements (cursor, vida, menu, pausa).
- No separate .cpp files for each class suggests header-only implementations or missing source stubs; either way, the architecture is class-based.

##### README for additional insights
- Confirms use of Allegro 4.x, Code::Blocks IDE, and C++.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Library
    subgraph "External Library"
        AL["Allegro 4.x"]:::external
    end

    %% Core Application
    subgraph "Core Application"
        GL["Game Loop\n(main.cpp)"]:::core
        GBL["Global Config\n(Global.h)"]:::core
    end

    %% Subsystems
    subgraph "Subsystems"
        IMS["Input Subsystem"]:::input
        RND["Rendering Engine"]:::render
        AM["Asset Manager"]:::asset
        UI["Menu & UI Controller"]:::logic
    end

    %% Game Logic Entities
    subgraph "Game Logic"
        PLY["Player (Personagem)"]:::logic
        ENM["Enemy (Inimigo)"]:::logic
        GRD["Ground"]:::logic
        LAD["Ladder (Escada)"]:::logic
        SHO["Shooting System"]:::logic
        LVM["Level Manager"]:::logic
    end

    %% Data Store
    SPR[(Sprites/)]:::data

    %% Initialization & Shutdown
    AL -->|"al_init()\nal_create_display()"| GL
    GL -->|"load assets"| AM
    SPR --> AM

    %% Game Loop Flow
    GL -->|"poll events"| IMS
    IMS -->|"forward events"| PLY
    IMS -->|"forward events"| UI

    UI -->|"control state"| GL

    GL -->|"update logic"| PLY
    GL -->|"update logic"| ENM
    GL -->|"update logic"| SHO
    GL -->|"update logic"| LVM
    GL -->|"collision check"| GRD
    GL -->|"collision check"| LAD

    GL -->|"draw frame"| RND
    AM -->|"provide textures"| RND
    AM -->|"provide textures"| PLY
    AM -->|"provide textures"| ENM
    AM -->|"provide textures"| UI

    GL -->|"shutdown"| AL

    %% Global Config References
    GBL -.-> IMS
    GBL -.-> RND
    GBL -.-> AM
    GBL -.-> GL

    %% Click Events
    click GL "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/main.cpp"
    click IMS "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/main.cpp"
    click RND "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/main.cpp"
    click AM "https://github.com/addamc/jogo_allegro/tree/Jogo-inteiro/Sprites/"
    click GBL "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/Global.h"
    click PLY "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/Personagem.h"
    click ENM "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/Inimigo.h"
    click GRD "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/Ground.h"
    click LAD "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/Escada.h"
    click SHO "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/Shooting.h"
    click LVM "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/LevelManager.h"
    click UI "https://github.com/addamc/jogo_allegro/blob/Jogo-inteiro/Menu.h"

    %% Styles
    classDef external fill:#cccccc,stroke:#333,stroke-width:1px
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef input fill:#bbf,stroke:#333,stroke-width:1px
    classDef render fill:#f90,stroke:#333,stroke-width:1px
    classDef asset fill:#ffb,stroke:#333,stroke-width:1px
    classDef logic fill:#bfb,stroke:#333,stroke-width:1px
    classDef data fill:#fcf,stroke:#333,stroke-width:1px,shape:database
```
