50  Sprite & State Definitions

This tour examines how DOOM uses sprite types and animation states through the info.h, p_mobj.h, and p_pspr.c headers and source files.


50.1 spritenum_t and statenum_t Enums

These enums define core identifiers for graphics and animation logic:

// spritenum_t assigns numeric values to sprite identifiers.
linuxdoom-1.10/info.h:30–37
// spritenum_t ends at NUMSPRITES.
linuxdoom-1.10/info.h:168–172
// statenum_t defines animation states.
linuxdoom-1.10/info.h:174–182
// NUMSTATES tracks how many animation states exist.
linuxdoom-1.10/info.h:1142–1145

50.2 state_t Struct

state_t uses spritenum_t and statenum_t for visual and behavioral sequencing:

// state_t's sprite field defines the graphic for the state.
linuxdoom-1.10/info.h:1149–1152
// nextstate field enables chaining animation frames.
linuxdoom-1.10/info.h:1154

50.3 Integration in Game Logic

// mobj_t uses spritenum_t for renderable sprites.
linuxdoom-1.10/p_mobj.h:222–224
// P_SetMobjState applies new statenum_t values to animate mobjs.
linuxdoom-1.10/p_mobj.c:54–57
// P_SetPsprite uses statenum_t values like S_PISTOL for weapon animation.
linuxdoom-1.10/p_pspr.c:59–62

50.4 Summary

  • spritenum_t defines renderable graphics.
  • statenum_t defines logical animation states.
  • state_t connects graphics to behavior, linking each frame to a sprite and next state.