Add P_LerpFlip

This commit is contained in:
James R 2022-09-25 07:42:52 -07:00
parent a6f206cd62
commit b5cdf25298
2 changed files with 16 additions and 0 deletions

View file

@ -44,6 +44,14 @@ INT32 P_AltFlip(INT32 n, tic_t tics)
return leveltime % (2 * tics) < tics ? n : -(n);
}
// Please read p_tick.h
INT32 P_LerpFlip(INT32 n, tic_t tics)
{
const tic_t w = 2 * tics;
return P_AltFlip(((leveltime % w) - tics) * n, w);
}
//
// THINKERS
// All thinkers should be allocated by Z_Calloc

View file

@ -35,4 +35,12 @@ mobj_t *P_SetTarget(mobj_t **mo, mobj_t *target); // killough 11/98
INT32 P_AltFlip(INT32 value, tic_t tics);
#define P_RandomFlip(value) P_AltFlip(value, 1)
// Multiply value back and forth between -(tics) and +(tics).
// Example output P_ModulateFlip(2, 2):
// Tic: 0 1 2 3 4 5 6 7 8
// Val: -4 -2 0 2 4 2 0 -2 -4
// A half cycle (one direction) takes 2 * tics.
// A full cycle takes 4 * tics.
INT32 P_LerpFlip(INT32 value, tic_t tics);
#endif