Add FF_REVERSEANIM frame flag

- Animate from state frame backwards by var1
This commit is contained in:
James R 2023-06-11 22:06:14 -07:00
parent b6e2609873
commit 8c4502ff5b
2 changed files with 10 additions and 2 deletions

View file

@ -154,11 +154,17 @@ FUNCINLINE static ATTRINLINE void P_CycleStateAnimation(mobj_t *mobj)
if (mobj->sprite != SPR_PLAY)
{
const UINT8 start = mobj->state->frame & FF_FRAMEMASK;
UINT8 frame = mobj->frame & FF_FRAMEMASK;
// compare the current sprite frame to the one we started from
// if more than var1 away from it, swap back to the original
// else just advance by one
if (((++mobj->frame) & FF_FRAMEMASK) - (mobj->state->frame & FF_FRAMEMASK) > (UINT32)mobj->state->var1)
mobj->frame = (mobj->state->frame & FF_FRAMEMASK) | (mobj->frame & ~FF_FRAMEMASK);
if ((mobj->frame & FF_REVERSEANIM ? (start - (--frame)) : ((++frame) - start)) > mobj->state->var1)
frame = start;
mobj->frame = frame | (mobj->frame & ~FF_FRAMEMASK);
return;
}

View file

@ -100,6 +100,8 @@ extern "C" {
#define FF_GLOBALANIM 0x20000000
/// \brief Frame flags - Animate: Start at a random place in the animation (mutually exclusive with above)
#define FF_RANDOMANIM 0x40000000
/// \brief Frame flags - Animate: Animate in reverse
#define FF_REVERSEANIM 0x80000000
/** \brief translucency tables