# id-software/wolf3d architecture

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

- Interactive diagram: https://gitdiagram.com/id-software/wolf3d
- Repository: https://github.com/id-software/wolf3d

## Overview

Wolfenstein 3D is a single-player, ray-cast action game whose user-facing loop is navigating levels, fighting enemies, collecting items, and reaching level completion. The source separates player control, actor behavior, level/game flow, rendering, and shared engine services for assets, input, video, and sound. The excerpts show selected calls and shared-header dependencies; several gameplay and rendering links are therefore represented as unverified rather than asserted as confirmed call chains.

Main entry points: [`WOLFSRC/WL_GAME.C`](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_GAME.C) (Game and level flow), [`WOLFSRC/WL_MAIN.C`](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_MAIN.C) (Startup and game setup), [`WOLFSRC/ID_CA.C`](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_CA.C) (Asset caching), [`WOLFSRC/WL_DEF.H`](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_DEF.H) (Shared game declarations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameplay["Gameplay"]
  node_player["Player control<br/>[WL_AGENT.C]"]
  node_actors["Enemy behavior<br/>[WL_ACT2.C]"]
  node_actorstate["Actor state and movement<br/>[WL_STATE.C]"]
  node_gameflow["Game and level flow<br/>[WL_GAME.C]"]
  node_main["Startup and game setup<br/>[WL_MAIN.C]"]
  node_gamedefs["Shared game declarations<br/>[WL_DEF.H]"]
end

subgraph group_world["World and rendering"]
  node_worldscan["Level object placement<br/>[WL_GAME.C]"]
  node_renderer["Ray-cast rendering<br/>[WL_DRAW.C]"]
  node_scaling["Wall scaling<br/>[WL_SCALE.C]"]
  node_legacy_scaling["Legacy scaling<br/>[OLDSCALE.C]"]
end

subgraph group_interface["User interface"]
  node_menus["Menus and settings<br/>[WL_MENU.C]"]
  node_intermission["Intermission and scores<br/>[WL_INTER.C]"]
  node_text["Game text<br/>[WL_TEXT.C]"]
end

subgraph group_engine["Engine services"]
  node_input["Input manager<br/>[ID_IN.C]"]
  node_video["Video manager<br/>[ID_VL.C]"]
  node_audio["Sound manager<br/>[ID_SD.C]"]
  node_cache["Asset caching<br/>[ID_CA.C]"]
  node_pages["Page manager<br/>[ID_PM.C]"]
  node_memory["Memory manager<br/>[ID_MM.C]"]
  node_controls["Shared engine declarations<br/>[ID_HEADS.H]"]
end

node_player_actor(("Player"))
node_game_data[("Released game data")]

node_player_actor -.->|"starts game"| node_main
node_main -.->|"opens menu"| node_menus
node_menus -.->|"starts level"| node_gameflow
node_gameflow -.->|"scans map"| node_worldscan
node_worldscan -.->|"spawns enemies"| node_actors
node_player -.->|"moves player"| node_actorstate
node_actors -.->|"updates actors"| node_actorstate
node_gameflow -.->|"shows results"| node_intermission
node_renderer -.->|"scales walls"| node_scaling
node_renderer -.->|"draws screen"| node_video
node_main -->|"sets view"| node_video
node_gameflow -->|"loads sounds"| node_cache
node_cache -.->|"loads sound data"| node_audio
node_intermission -->|"plays sounds"| node_audio
node_actorstate -->|"plays sounds"| node_audio
node_menus -.->|"reads controls"| node_input
node_cache -.->|"uses pages"| node_pages
node_pages -.->|"allocates pages"| node_memory
node_game_data -.->|"supplies assets"| node_cache
node_main -.->|"includes declarations"| node_controls
node_gameflow -->|"includes declarations"| node_gamedefs
node_actors -->|"includes declarations"| node_gamedefs
node_renderer -->|"includes declarations"| node_gamedefs
node_gamedefs -->|"includes declarations"| node_controls

click node_player "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_AGENT.C"
click node_actors "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_ACT2.C"
click node_actorstate "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_STATE.C"
click node_gameflow "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_GAME.C"
click node_main "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_MAIN.C"
click node_worldscan "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_GAME.C"
click node_renderer "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_DRAW.C"
click node_scaling "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_SCALE.C"
click node_legacy_scaling "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/OLDSCALE.C"
click node_menus "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_MENU.C"
click node_intermission "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_INTER.C"
click node_text "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_TEXT.C"
click node_input "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_IN.C"
click node_video "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_VL.C"
click node_audio "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_SD.C"
click node_cache "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_CA.C"
click node_pages "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_PM.C"
click node_memory "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_MM.C"
click node_controls "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_HEADS.H"
click node_gamedefs "https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_DEF.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_player,node_actors,node_actorstate,node_gameflow,node_main,node_gamedefs toneBlue
class node_worldscan,node_renderer,node_scaling,node_legacy_scaling,node_game_data toneAmber
class node_menus,node_intermission,node_text toneMint
class node_input,node_video,node_audio,node_cache,node_pages,node_memory,node_controls toneRose
class node_player_actor toneIndigo
```

## Components

### Gameplay

- [Player control](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_AGENT.C): `WOLFSRC/WL_AGENT.C`
- [Enemy behavior](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_ACT2.C): `WOLFSRC/WL_ACT2.C`
- [Actor state and movement](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_STATE.C): `WOLFSRC/WL_STATE.C`
- [Game and level flow](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_GAME.C): `WOLFSRC/WL_GAME.C`
- [Startup and game setup](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_MAIN.C): `WOLFSRC/WL_MAIN.C`
- [Shared game declarations](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_DEF.H): `WOLFSRC/WL_DEF.H`

### World and rendering

- [Level object placement](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_GAME.C): `WOLFSRC/WL_GAME.C`
- [Ray-cast rendering](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_DRAW.C): `WOLFSRC/WL_DRAW.C`
- [Wall scaling](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_SCALE.C): `WOLFSRC/WL_SCALE.C`
- [Legacy scaling](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/OLDSCALE.C): `WOLFSRC/OLDSCALE.C`

### User interface

- [Menus and settings](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_MENU.C): `WOLFSRC/WL_MENU.C`
- [Intermission and scores](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_INTER.C): `WOLFSRC/WL_INTER.C`
- [Game text](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/WL_TEXT.C): `WOLFSRC/WL_TEXT.C`

### Engine services

- [Input manager](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_IN.C): `WOLFSRC/ID_IN.C`
- [Video manager](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_VL.C): `WOLFSRC/ID_VL.C`
- [Sound manager](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_SD.C): `WOLFSRC/ID_SD.C`
- [Asset caching](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_CA.C): `WOLFSRC/ID_CA.C`
- [Page manager](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_PM.C): `WOLFSRC/ID_PM.C`
- [Memory manager](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_MM.C): `WOLFSRC/ID_MM.C`
- [Shared engine declarations](https://github.com/id-software/wolf3d/blob/master/WOLFSRC/ID_HEADS.H): `WOLFSRC/ID_HEADS.H`

### Other components

- **Player**
- **Released game data**

## Connections

- Player → Startup and game setup: starts game
- Startup and game setup → Menus and settings: opens menu
- Menus and settings → Game and level flow: starts level
- Game and level flow → Level object placement: scans map (evidence: `WOLFSRC/WL_GAME.C`)
- Level object placement → Enemy behavior: spawns enemies
- Player control → Actor state and movement: moves player
- Enemy behavior → Actor state and movement: updates actors
- Game and level flow → Intermission and scores: shows results
- Ray-cast rendering → Wall scaling: scales walls
- Ray-cast rendering → Video manager: draws screen
- Startup and game setup → Video manager: sets view (evidence: `WOLFSRC/WL_MAIN.C`)
- Game and level flow → Asset caching: loads sounds (evidence: `WOLFSRC/WL_GAME.C`)
- Asset caching → Sound manager: loads sound data
- Intermission and scores → Sound manager: plays sounds (evidence: `WOLFSRC/WL_INTER.C`)
- Actor state and movement → Sound manager: plays sounds (evidence: `WOLFSRC/WL_STATE.C`)
- Menus and settings → Input manager: reads controls
- Asset caching → Page manager: uses pages
- Page manager → Memory manager: allocates pages
- Released game data → Asset caching: supplies assets
- Startup and game setup → Shared engine declarations: includes declarations
- Game and level flow → Shared game declarations: includes declarations (evidence: `WOLFSRC/WL_GAME.C`)
- Enemy behavior → Shared game declarations: includes declarations (evidence: `WOLFSRC/WL_ACT2.C`)
- Ray-cast rendering → Shared game declarations: includes declarations (evidence: `WOLFSRC/WL_DRAW.C`)
- Shared game declarations → Shared engine declarations: includes declarations (evidence: `WOLFSRC/WL_DEF.H`)
