Actors, States, and the Play Loop

Actors, States, and the Play Loop

Wolfenstein’s enemies, projectiles, doors, and player interactions are represented through compact game-specific structures and state transitions rather than a broad object framework. WL_DEF.H provides much of the shared vocabulary, while WL_ACT1.C, WL_ACT2.C, WL_AGENT.C, WL_PLAY.C, and WL_GAME.C divide actor behavior, player control, and level progression.

The play loop advancing actors through named state transitions

The play loop gathers control input, updates the player, advances active actors, resolves movement and combat, and then renders the resulting world. Actor states encode animations and behavior timing through data that identifies what action to perform and which state follows. The consequence is a compact finite-state model: a guard can stand, patrol, chase, attack, take damage, or die by transitioning through authored state records rather than by executing a large per-frame behavioral script.

When reading the source, keep spatial movement and state progression separate. The state system determines what the actor is attempting and how long it remains in a mode; collision and map logic determine whether a positional move is actually permitted. This distinction makes it easier to trace why an actor changed behavior versus why it could not reach a location.