# rubenteles/cub3d architecture

> Architecture diagram of the GitHub repository rubenteles/cub3d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rubenteles/cub3d
- Repository: https://github.com/rubenteles/cub3d

## Overview

Cub3D is a Wolfenstein-style ray-casting game built with miniLibX. The user supplies a .cub map, which the program reads and converts before starting the game; the engine then runs the interactive loop, rendering scenes and handling movement, combat, and interactions. Documented capabilities also include menus, pause, tasks, weather changes, and sound. The map-loading and engine excerpts show the startup and loop; several feature links are documented but their implementation wiring was not sampled, so those links are marked unverified.

Main entry points: [`src/main/main.c`](https://github.com/rubenteles/cub3d/blob/main/src/main/main.c) (Game Entry), [`src/engine/ft_engine.c`](https://github.com/rubenteles/cub3d/blob/main/src/engine/ft_engine.c) (Game Loop), [`src/objects/player.c`](https://github.com/rubenteles/cub3d/blob/main/src/objects/player.c) (Player Actions), [`src/raycasting/ft_raycasting.c`](https://github.com/rubenteles/cub3d/blob/main/src/raycasting/ft_raycasting.c) (Ray Casting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Startup and Map"]
  node_main["Game Entry<br/>[main.c]"]
  node_map_reader["Map Reader<br/>[ft_map.c]"]
  node_map_data["Map State<br/>[ft_cub.h]"]
end

subgraph group_runtime["Game Runtime"]
  node_engine["Engine Setup<br/>[ft_new_engine.c]"]
  node_game_loop["Game Loop<br/>[ft_engine.c]"]
  node_input["Input Handling"]
  node_player["Player Actions<br/>[player.c]"]
  node_objects["Objects and Enemies<br/>[obj_managment.c]"]
  node_combat["Combat"]
  node_sound["Sound<br/>[ft_sound.c]"]
end

subgraph group_presentation["Rendering and Scenes"]
  node_raycaster["Ray Casting<br/>[ft_raycasting.c]"]
  node_floor["Floor Rendering"]
  node_sprites["Sprite Rendering<br/>[ft_print_sprites.c]"]
  node_canvas["Canvas Drawing<br/>[ft_canvas.c]"]
  node_scene_manager["Scene Management<br/>[scenes_managment.c]"]
  node_scene_images["Scene Images"]
  node_task_overlay["Task Overlay<br/>[c_tasks.c]"]
end

subgraph group_platform["Graphics Platform"]
  node_mlx_internal["MLX Internals<br/>[mlx_int.h]"]
  node_mlx_images["MLX Images<br/>[mlx_new_image.c]"]
  node_mlx_colors["MLX Color Names<br/>[mlx_rgb.c]"]
  node_mlx_xpm["MLX XPM Loader<br/>[mlx_xpm.c]"]
end

node_user(("Player"))

node_user -.->|"starts game"| node_main
node_main -->|"loads map"| node_map_reader
node_main -->|"builds map state"| node_map_data
node_main -->|"starts engine"| node_engine
node_engine -.->|"starts loop"| node_game_loop
node_game_loop -->|"shows scenes"| node_canvas
node_game_loop -->|"displays frame"| node_user
node_user -.->|"presses controls"| node_input
node_input -.->|"moves and interacts"| node_player
node_player -->|"checks interactions"| node_objects
node_player -.->|"dispatches attacks"| node_combat
node_user -.->|"hears game audio"| node_sound
node_scene_manager -.->|"selects game view"| node_raycaster
node_raycaster -.->|"renders floor"| node_floor
node_raycaster -->|"renders sprites"| node_sprites
node_canvas -.->|"draws scenes"| node_scene_manager
node_scene_images -.->|"includes tasks"| node_task_overlay
node_task_overlay -.->|"shows progress"| node_user
node_mlx_images -->|"uses internals"| node_mlx_internal
node_mlx_xpm -->|"uses internals"| node_mlx_internal
node_mlx_colors -->|"uses internals"| node_mlx_internal

click node_main "https://github.com/rubenteles/cub3d/blob/main/src/main/main.c"
click node_map_reader "https://github.com/rubenteles/cub3d/blob/main/src/map/ft_map.c"
click node_map_data "https://github.com/rubenteles/cub3d/blob/main/hdr/ft_cub.h"
click node_engine "https://github.com/rubenteles/cub3d/blob/main/src/engine/ft_new_engine.c"
click node_game_loop "https://github.com/rubenteles/cub3d/blob/main/src/engine/ft_engine.c"
click node_input "https://github.com/rubenteles/cub3d/blob/main/src/engine/key/ft_key_management.c"
click node_player "https://github.com/rubenteles/cub3d/blob/main/src/objects/player.c"
click node_objects "https://github.com/rubenteles/cub3d/blob/main/src/objects/obj_managment.c"
click node_combat "https://github.com/rubenteles/cub3d/blob/main/src/objects/breath_atack/player_atack_breath.c"
click node_sound "https://github.com/rubenteles/cub3d/blob/main/src/engine/ft_sound.c"
click node_raycaster "https://github.com/rubenteles/cub3d/blob/main/src/raycasting/ft_raycasting.c"
click node_floor "https://github.com/rubenteles/cub3d/blob/main/src/raycasting/ft_floor_raycasting.c"
click node_sprites "https://github.com/rubenteles/cub3d/blob/main/src/raycasting/ft_print_sprites.c"
click node_canvas "https://github.com/rubenteles/cub3d/blob/main/src/canva/ft_canvas.c"
click node_scene_manager "https://github.com/rubenteles/cub3d/blob/main/src/canva/scenes/scenes_managment.c"
click node_scene_images "https://github.com/rubenteles/cub3d/blob/main/src/canva/scenes/new_scenes_images.c"
click node_task_overlay "https://github.com/rubenteles/cub3d/blob/main/src/canva/scenes/scenes_images/c_tasks.c"
click node_mlx_internal "https://github.com/rubenteles/cub3d/blob/main/mlx_linux/mlx_int.h"
click node_mlx_images "https://github.com/rubenteles/cub3d/blob/main/mlx_linux/mlx_new_image.c"
click node_mlx_colors "https://github.com/rubenteles/cub3d/blob/main/mlx_linux/mlx_rgb.c"
click node_mlx_xpm "https://github.com/rubenteles/cub3d/blob/main/mlx_linux/mlx_xpm.c"

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_map_reader,node_map_data toneBlue
class node_engine,node_game_loop,node_input,node_player,node_objects,node_combat,node_sound toneAmber
class node_raycaster,node_floor,node_sprites,node_canvas,node_scene_manager,node_scene_images,node_task_overlay toneMint
class node_mlx_internal,node_mlx_images,node_mlx_colors,node_mlx_xpm toneRose
class node_user toneIndigo
```

## Components

### Startup and Map

- [Game Entry](https://github.com/rubenteles/cub3d/blob/main/src/main/main.c): `src/main/main.c`
- [Map Reader](https://github.com/rubenteles/cub3d/blob/main/src/map/ft_map.c): `src/map/ft_map.c`
- [Map State](https://github.com/rubenteles/cub3d/blob/main/hdr/ft_cub.h): `hdr/ft_cub.h`

### Game Runtime

- [Engine Setup](https://github.com/rubenteles/cub3d/blob/main/src/engine/ft_new_engine.c): `src/engine/ft_new_engine.c`
- [Game Loop](https://github.com/rubenteles/cub3d/blob/main/src/engine/ft_engine.c): `src/engine/ft_engine.c`
- [Input Handling](https://github.com/rubenteles/cub3d/blob/main/src/engine/key/ft_key_management.c): `src/engine/key/ft_key_management.c`
- [Player Actions](https://github.com/rubenteles/cub3d/blob/main/src/objects/player.c): `src/objects/player.c`
- [Objects and Enemies](https://github.com/rubenteles/cub3d/blob/main/src/objects/obj_managment.c): `src/objects/obj_managment.c`
- [Combat](https://github.com/rubenteles/cub3d/blob/main/src/objects/breath_atack/player_atack_breath.c): `src/objects/breath_atack/player_atack_breath.c`
- [Sound](https://github.com/rubenteles/cub3d/blob/main/src/engine/ft_sound.c): `src/engine/ft_sound.c`

### Rendering and Scenes

- [Ray Casting](https://github.com/rubenteles/cub3d/blob/main/src/raycasting/ft_raycasting.c): `src/raycasting/ft_raycasting.c`
- [Floor Rendering](https://github.com/rubenteles/cub3d/blob/main/src/raycasting/ft_floor_raycasting.c): `src/raycasting/ft_floor_raycasting.c`
- [Sprite Rendering](https://github.com/rubenteles/cub3d/blob/main/src/raycasting/ft_print_sprites.c): `src/raycasting/ft_print_sprites.c`
- [Canvas Drawing](https://github.com/rubenteles/cub3d/blob/main/src/canva/ft_canvas.c): `src/canva/ft_canvas.c`
- [Scene Management](https://github.com/rubenteles/cub3d/blob/main/src/canva/scenes/scenes_managment.c): `src/canva/scenes/scenes_managment.c`
- [Scene Images](https://github.com/rubenteles/cub3d/blob/main/src/canva/scenes/new_scenes_images.c): `src/canva/scenes/new_scenes_images.c`
- [Task Overlay](https://github.com/rubenteles/cub3d/blob/main/src/canva/scenes/scenes_images/c_tasks.c): `src/canva/scenes/scenes_images/c_tasks.c`

### Graphics Platform

- [MLX Internals](https://github.com/rubenteles/cub3d/blob/main/mlx_linux/mlx_int.h): `mlx_linux/mlx_int.h`
- [MLX Images](https://github.com/rubenteles/cub3d/blob/main/mlx_linux/mlx_new_image.c): `mlx_linux/mlx_new_image.c`
- [MLX Color Names](https://github.com/rubenteles/cub3d/blob/main/mlx_linux/mlx_rgb.c): `mlx_linux/mlx_rgb.c`
- [MLX XPM Loader](https://github.com/rubenteles/cub3d/blob/main/mlx_linux/mlx_xpm.c): `mlx_linux/mlx_xpm.c`

### Other components

- **Player**

## Connections

- Player → Game Entry: starts game
- Game Entry → Map Reader: loads map (evidence: `src/main/main.c`)
- Game Entry → Map State: builds map state (evidence: `src/main/main.c`)
- Game Entry → Engine Setup: starts engine (evidence: `src/main/main.c`)
- Engine Setup → Game Loop: starts loop
- Game Loop → Canvas Drawing: shows scenes (evidence: `src/engine/ft_engine.c`)
- Game Loop → Player: displays frame (evidence: `src/engine/ft_engine.c`)
- Player → Input Handling: presses controls
- Input Handling → Player Actions: moves and interacts
- Player Actions → Objects and Enemies: checks interactions (evidence: `src/objects/player.c`)
- Player Actions → Combat: dispatches attacks
- Player → Sound: hears game audio
- Scene Management → Ray Casting: selects game view
- Ray Casting → Floor Rendering: renders floor
- Ray Casting → Sprite Rendering: renders sprites (evidence: `src/raycasting/ft_raycasting.c`)
- Canvas Drawing → Scene Management: draws scenes
- Scene Images → Task Overlay: includes tasks
- Task Overlay → Player: shows progress
- MLX Images → MLX Internals: uses internals (evidence: `mlx_linux/mlx_new_image.c`)
- MLX XPM Loader → MLX Internals: uses internals (evidence: `mlx_linux/mlx_xpm.c`)
- MLX Color Names → MLX Internals: uses internals (evidence: `mlx_linux/mlx_rgb.c`)
