# ats-xp/atacadao-nightmare architecture

> Architecture diagram of the GitHub repository ats-xp/atacadao-nightmare, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ats-xp/atacadao-nightmare
- Repository: https://github.com/ats-xp/atacadao-nightmare

## Overview

Atacadão - Nightmare is a C++ 3D first-person shooter built around a small game engine. Its visible runtime starts in `source/main.cpp`, which initializes SDL and Sokol, dispatches events and frame updates to the active state, and renders that state. The product tree indicates gameplay, map/physics, and 3D presentation subsystems; sampled code confirms texture management, model loading, map parsing, and physics setup. Gameplay wiring beyond the main state loop is inferred from the module layout, so those connections are omitted where caller evidence is unavailable.

Main entry points: [`source/main.cpp`](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/main.cpp) (Runtime loop), [`source/model.cpp`](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/model.cpp) (Model processing), [`source/asset_manager.cpp`](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/asset_manager.cpp) (Asset manager), [`source/map.cpp`](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/map.cpp) (Map loading)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application flow"]
  node_main["Runtime loop<br/>[main.cpp]"]
  node_state["Game state<br/>[state.hpp]"]
  node_menu["Menu state<br/>[menu.cpp]"]
end

subgraph group_play["Gameplay"]
  node_game["Game state<br/>[game.cpp]"]
  node_player["Player character<br/>[player.cpp]"]
  node_bullet["Projectiles<br/>[bullet.cpp]"]
  node_dummy["Dummy actors<br/>[dummy.cpp]"]
  node_gameobj["Game objects<br/>[game_object.hpp]"]
end

subgraph group_world["World and rendering"]
  node_map["Map loading<br/>[map.cpp]"]
  node_camera["Camera<br/>[camera.cpp]"]
  node_model["Model processing<br/>[model.cpp]"]
  node_mesh["Mesh rendering<br/>[mesh.cpp]"]
  node_render["Render system<br/>[render.cpp]"]
  node_billboard["Billboards<br/>[billboard.cpp]"]
  node_animation["Sprite animation<br/>[sprite_anim.cpp]"]
end

subgraph group_runtime["Engine services"]
  node_assets[("Asset manager<br/>[asset_manager.cpp]")]
  node_physics["Physics manager"]
  node_sdl["SDL integration<br/>[sdl2_glue.cpp]"]
end

node_user(("Player"))
node_sokol["Sokol graphics"]
node_physx["PhysX"]
node_fetch["Async fetch"]

node_user -->|"sends events"| node_main
node_main -->|"initializes window"| node_sdl
node_main -->|"dispatches events"| node_state
node_main -->|"updates and renders"| node_state
node_main -->|"switches state"| node_menu
node_main -->|"switches state"| node_game
node_main -->|"submits frames"| node_sokol
node_map -->|"loads model"| node_model
node_map -->|"reads map path"| node_assets
node_map -->|"sets up collision"| node_physics
node_model -->|"loads textures"| node_assets
node_model -->|"draws meshes"| node_mesh
node_model -->|"submits draw data"| node_sokol
node_physics -->|"simulates scene"| node_physx
node_assets -->|"creates images"| node_sokol
node_assets -.->|"requests textures"| node_fetch

click node_main "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/main.cpp"
click node_state "https://github.com/ats-xp/atacadao-nightmare/blob/main/include/state.hpp"
click node_menu "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/menu.cpp"
click node_game "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/game.cpp"
click node_player "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/player.cpp"
click node_bullet "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/bullet.cpp"
click node_dummy "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/dummy.cpp"
click node_gameobj "https://github.com/ats-xp/atacadao-nightmare/blob/main/include/game_object.hpp"
click node_map "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/map.cpp"
click node_camera "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/camera.cpp"
click node_model "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/model.cpp"
click node_mesh "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/mesh.cpp"
click node_render "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/render.cpp"
click node_billboard "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/billboard.cpp"
click node_animation "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/sprite_anim.cpp"
click node_assets "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/asset_manager.cpp"
click node_physics "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/physics_manager.cpp"
click node_sdl "https://github.com/ats-xp/atacadao-nightmare/blob/main/source/sdl2_glue.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_state,node_menu toneBlue
class node_game,node_player,node_bullet,node_dummy,node_gameobj toneAmber
class node_map,node_camera,node_model,node_mesh,node_render,node_billboard,node_animation toneMint
class node_assets,node_physics,node_sdl toneRose
class node_user,node_sokol,node_physx,node_fetch toneIndigo
```

## Components

### Application flow

- [Runtime loop](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/main.cpp): `source/main.cpp`
- [Game state](https://github.com/ats-xp/atacadao-nightmare/blob/main/include/state.hpp): `include/state.hpp`
- [Menu state](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/menu.cpp): `source/menu.cpp`

### Gameplay

- [Game state](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/game.cpp): `source/game.cpp`
- [Player character](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/player.cpp): `source/player.cpp`
- [Projectiles](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/bullet.cpp): `source/bullet.cpp`
- [Dummy actors](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/dummy.cpp): `source/dummy.cpp`
- [Game objects](https://github.com/ats-xp/atacadao-nightmare/blob/main/include/game_object.hpp): `include/game_object.hpp`

### World and rendering

- [Map loading](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/map.cpp): `source/map.cpp`
- [Camera](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/camera.cpp): `source/camera.cpp`
- [Model processing](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/model.cpp): `source/model.cpp`
- [Mesh rendering](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/mesh.cpp): `source/mesh.cpp`
- [Render system](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/render.cpp): `source/render.cpp`
- [Billboards](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/billboard.cpp): `source/billboard.cpp`
- [Sprite animation](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/sprite_anim.cpp): `source/sprite_anim.cpp`

### Engine services

- [Asset manager](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/asset_manager.cpp): `source/asset_manager.cpp`
- [Physics manager](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/physics_manager.cpp): `source/physics_manager.cpp`
- [SDL integration](https://github.com/ats-xp/atacadao-nightmare/blob/main/source/sdl2_glue.cpp): `source/sdl2_glue.cpp`

### Other components

- **Player**
- **Sokol graphics**
- **PhysX**
- **Async fetch**

## Connections

- Player → Runtime loop: sends events
- Runtime loop → SDL integration: initializes window
- Runtime loop → Game state: dispatches events
- Runtime loop → Game state: updates and renders
- Runtime loop → Menu state: switches state
- Runtime loop → Game state: switches state
- Runtime loop → Sokol graphics: submits frames
- Map loading → Model processing: loads model
- Map loading → Asset manager: reads map path
- Map loading → Physics manager: sets up collision
- Model processing → Asset manager: loads textures
- Model processing → Mesh rendering: draws meshes
- Model processing → Sokol graphics: submits draw data
- Physics manager → PhysX: simulates scene
- Asset manager → Sokol graphics: creates images
- Asset manager → Async fetch: requests textures
