38 Player Movement & Weapon Sprites
This tour covers movement logic in p_user.c
and weapon display in p_pspr.h/c
.
38.0.1 p_user.c
: Player Movement
P_Thrust
applies acceleration to the player’s momentum along a given angle (lines 64–68
).MAXBOB
(lines 48–49
) defines view bobbing height.- View bob is calculated from squared momentum (
lines 88–96
). - Final view height includes bob offset and ceiling check (
lines 136–141
). - Player direction and ground status are updated (
lines 154–158
). - Movement inputs are converted to momentum via
P_Thrust
(lines 160–163
). - Transition to running animation (
lines 166–169
). P_PlayerThink
processes commands and updates state per tick (lines 236–242
).
P_PlayerThink
also handles: cheat codes, death state, movement, view bobbing, sector effects, weapon switching, use-line actions, weapon animations, and power-up timers.
38.0.2 p_pspr.h
and p_pspr.c
: Weapon Sprites
P_SetupPsprites
clears weapon sprite states (lines 831–838
).pspdef_t
defines overlay sprite structure (lines 68–75
inp_pspr.h
).P_MovePsprites
updates animation states (lines 851–861
).pspdef_t
also used ininfo.c
for:- animation state (
line 138
) - weapon sprite tracking (
line 146
) - screen position and state control (
line 154
)
- animation state (
And that was the walkthrough of player movement, view bobbing, and weapon sprite animation.