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:3037
// spritenum_t ends at NUMSPRITES.
linuxdoom-1.10/info.h:168172
// statenum_t defines animation states.
linuxdoom-1.10/info.h:174182
// NUMSTATES tracks how many animation states exist.
linuxdoom-1.10/info.h:11421145

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:11491152
// 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:222224
// P_SetMobjState applies new statenum_t values to animate mobjs.
linuxdoom-1.10/p_mobj.c:5457
// P_SetPsprite uses statenum_t values like S_PISTOL for weapon animation.
linuxdoom-1.10/p_pspr.c:5962

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.