# myivanov-c/cub3d architecture

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

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

## Overview

cub3D is a MiniLibX-based, Star Wars-themed raycasting game. The user supplies a .cub level and launches the game; the documented runtime validates level data, renders a first-person view, and supports movement, camera control, doors, a minimap, and lightsaber animations. The graph preserves these documented capabilities and the libft support layer. Some subsystem links rely on the README because their implementation files were not sampled; uncertain call relationships are omitted.

Main entry points: [`src/parser.c`](https://github.com/myivanov-c/cub3d/blob/main/src/parser.c) (Level parser), [`src/read_file.c`](https://github.com/myivanov-c/cub3d/blob/main/src/read_file.c) (Level file input), [`src/rays.c`](https://github.com/myivanov-c/cub3d/blob/main/src/rays.c) (Raycasting), [`src/run_weapon_animation.c`](https://github.com/myivanov-c/cub3d/blob/main/src/run_weapon_animation.c) (Weapon animation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Game entry and setup"]
  node_main["Game entry<br/>[main.c]"]
  node_setup["Runtime setup<br/>[start.c]"]
end

subgraph group_world["Level and world"]
  node_file["Level file input<br/>[read_file.c]"]
  node_parser["Level parser<br/>[parser.c]"]
  node_elements["Texture and color checks<br/>[check_elements.c]"]
  node_mapcheck["Map validation<br/>[check_map.c]"]
  node_textures["Texture loading<br/>[textures.c]"]
end

subgraph group_render["Rendering"]
  node_rays["Raycasting<br/>[rays.c]"]
  node_dda["Grid traversal<br/>[dda.c]"]
  node_walls["Wall rendering<br/>[draw.c]"]
  node_floor["Floor and ceiling<br/>[draw_fc.c]"]
  node_floortex["Texture projection"]
  node_minimap["Minimap overlay<br/>[minimap.c]"]
end

subgraph group_gameplay["Gameplay"]
  node_input["Keyboard controls<br/>[handle_inputs.c]"]
  node_movement["Movement and collision<br/>[move.c]"]
  node_mouse["Mouse look<br/>[handle_mouse.c]"]
  node_doors["Door interaction<br/>[doors.c]"]
  node_doorcheck["Door collision checks<br/>[check_doors.c]"]
  node_weapon["Weapon animation"]
  node_hud["Weapon HUD<br/>[draw_weapon_hud.c]"]
  node_attackhud["Attack HUD<br/>[draw_attack_hud.c]"]
end

subgraph group_support["C support"]
  node_libft["libft utilities<br/>[libft.h]"]
  node_gnl["Line reader<br/>[get_next_line.h]"]
end

node_user(("Player"))
node_mlx["MiniLibX"]

node_user -->|"launches"| node_main
node_main -->|"starts"| node_setup
node_file -->|"supplies level"| node_parser
node_parser -->|"checks elements"| node_elements
node_parser -->|"validates map"| node_mapcheck
node_rays -->|"traverses grid"| node_dda
node_rays -->|"renders walls"| node_walls
node_floor -->|"projects textures"| node_floortex
node_input -->|"controls movement"| node_movement
node_doors -->|"handles collision"| node_doorcheck
node_weapon -->|"shows weapon"| node_hud
node_weapon -->|"shows attacks"| node_attackhud
node_file -.->|"reads lines"| node_gnl
node_setup -->|"uses graphics"| node_mlx

click node_main "https://github.com/myivanov-c/cub3d/blob/main/src/main.c"
click node_setup "https://github.com/myivanov-c/cub3d/blob/main/src/start.c"
click node_file "https://github.com/myivanov-c/cub3d/blob/main/src/read_file.c"
click node_parser "https://github.com/myivanov-c/cub3d/blob/main/src/parser.c"
click node_elements "https://github.com/myivanov-c/cub3d/blob/main/src/check_elements.c"
click node_mapcheck "https://github.com/myivanov-c/cub3d/blob/main/src/check_map.c"
click node_textures "https://github.com/myivanov-c/cub3d/blob/main/src/textures.c"
click node_rays "https://github.com/myivanov-c/cub3d/blob/main/src/rays.c"
click node_dda "https://github.com/myivanov-c/cub3d/blob/main/src/dda.c"
click node_walls "https://github.com/myivanov-c/cub3d/blob/main/src/draw.c"
click node_floor "https://github.com/myivanov-c/cub3d/blob/main/src/draw_fc.c"
click node_floortex "https://github.com/myivanov-c/cub3d/blob/main/src/handle_floor_ceiling.c"
click node_minimap "https://github.com/myivanov-c/cub3d/blob/main/src/minimap.c"
click node_input "https://github.com/myivanov-c/cub3d/blob/main/src/handle_inputs.c"
click node_movement "https://github.com/myivanov-c/cub3d/blob/main/src/move.c"
click node_mouse "https://github.com/myivanov-c/cub3d/blob/main/src/handle_mouse.c"
click node_doors "https://github.com/myivanov-c/cub3d/blob/main/src/doors.c"
click node_doorcheck "https://github.com/myivanov-c/cub3d/blob/main/src/check_doors.c"
click node_weapon "https://github.com/myivanov-c/cub3d/blob/main/src/run_weapon_animation.c"
click node_hud "https://github.com/myivanov-c/cub3d/blob/main/src/draw_weapon_hud.c"
click node_attackhud "https://github.com/myivanov-c/cub3d/blob/main/src/draw_attack_hud.c"
click node_libft "https://github.com/myivanov-c/cub3d/blob/main/inc/libft/libft.h"
click node_gnl "https://github.com/myivanov-c/cub3d/blob/main/inc/libft/get_next_line.h"

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_setup toneBlue
class node_file,node_parser,node_elements,node_mapcheck,node_textures toneAmber
class node_rays,node_dda,node_walls,node_floor,node_floortex,node_minimap toneMint
class node_input,node_movement,node_mouse,node_doors,node_doorcheck,node_weapon,node_hud,node_attackhud toneRose
class node_libft,node_gnl,node_user,node_mlx toneIndigo
```

## Components

### Game entry and setup

- [Game entry](https://github.com/myivanov-c/cub3d/blob/main/src/main.c): `src/main.c`
- [Runtime setup](https://github.com/myivanov-c/cub3d/blob/main/src/start.c): `src/start.c`

### Level and world

- [Level file input](https://github.com/myivanov-c/cub3d/blob/main/src/read_file.c): `src/read_file.c`
- [Level parser](https://github.com/myivanov-c/cub3d/blob/main/src/parser.c): `src/parser.c`
- [Texture and color checks](https://github.com/myivanov-c/cub3d/blob/main/src/check_elements.c): `src/check_elements.c`
- [Map validation](https://github.com/myivanov-c/cub3d/blob/main/src/check_map.c): `src/check_map.c`
- [Texture loading](https://github.com/myivanov-c/cub3d/blob/main/src/textures.c): `src/textures.c`

### Rendering

- [Raycasting](https://github.com/myivanov-c/cub3d/blob/main/src/rays.c): `src/rays.c`
- [Grid traversal](https://github.com/myivanov-c/cub3d/blob/main/src/dda.c): `src/dda.c`
- [Wall rendering](https://github.com/myivanov-c/cub3d/blob/main/src/draw.c): `src/draw.c`
- [Floor and ceiling](https://github.com/myivanov-c/cub3d/blob/main/src/draw_fc.c): `src/draw_fc.c`
- [Texture projection](https://github.com/myivanov-c/cub3d/blob/main/src/handle_floor_ceiling.c): `src/handle_floor_ceiling.c`
- [Minimap overlay](https://github.com/myivanov-c/cub3d/blob/main/src/minimap.c): `src/minimap.c`

### Gameplay

- [Keyboard controls](https://github.com/myivanov-c/cub3d/blob/main/src/handle_inputs.c): `src/handle_inputs.c`
- [Movement and collision](https://github.com/myivanov-c/cub3d/blob/main/src/move.c): `src/move.c`
- [Mouse look](https://github.com/myivanov-c/cub3d/blob/main/src/handle_mouse.c): `src/handle_mouse.c`
- [Door interaction](https://github.com/myivanov-c/cub3d/blob/main/src/doors.c): `src/doors.c`
- [Door collision checks](https://github.com/myivanov-c/cub3d/blob/main/src/check_doors.c): `src/check_doors.c`
- [Weapon animation](https://github.com/myivanov-c/cub3d/blob/main/src/run_weapon_animation.c): `src/run_weapon_animation.c`
- [Weapon HUD](https://github.com/myivanov-c/cub3d/blob/main/src/draw_weapon_hud.c): `src/draw_weapon_hud.c`
- [Attack HUD](https://github.com/myivanov-c/cub3d/blob/main/src/draw_attack_hud.c): `src/draw_attack_hud.c`

### C support

- [libft utilities](https://github.com/myivanov-c/cub3d/blob/main/inc/libft/libft.h): `inc/libft/libft.h`
- [Line reader](https://github.com/myivanov-c/cub3d/blob/main/inc/libft/get_next_line.h): `inc/libft/get_next_line.h`

### Other components

- **Player**
- **MiniLibX**

## Connections

- Player → Game entry: launches
- Game entry → Runtime setup: starts
- Level file input → Level parser: supplies level
- Level parser → Texture and color checks: checks elements
- Level parser → Map validation: validates map
- Raycasting → Grid traversal: traverses grid
- Raycasting → Wall rendering: renders walls
- Floor and ceiling → Texture projection: projects textures
- Keyboard controls → Movement and collision: controls movement
- Door interaction → Door collision checks: handles collision
- Weapon animation → Weapon HUD: shows weapon
- Weapon animation → Attack HUD: shows attacks
- Level file input → Line reader: reads lines
- Runtime setup → MiniLibX: uses graphics
