Merge branch 'broly-ease' into 'master'

Use sinusoidial interpolation for Broly ki

See merge request KartKrew/Kart!811
This commit is contained in:
Sal 2022-12-17 23:44:16 +00:00
commit 60d2f250b7
3 changed files with 41 additions and 6 deletions

View file

@ -56,5 +56,6 @@ void Obj_DuelBombInit(mobj_t *bomb);
/* Broly Ki */
mobj_t *Obj_SpawnBrolyKi(mobj_t *source, tic_t duration);
void Obj_BrolyKiThink(mobj_t *ki);
#endif/*k_objects_H*/

View file

@ -2,9 +2,33 @@
#include "../info.h"
#include "../k_kart.h"
#include "../k_objects.h"
#include "../m_easing.h"
#include "../p_local.h"
#include "../s_sound.h"
// TODO: generic function
static void P_InstaScale(mobj_t *thing, fixed_t scale)
{
P_SetScale(thing, scale);
thing->destscale = scale;
}
/* An object may not be visible on the same tic:
1) that it spawned
2) that it cycles to the next state */
#define BUFFER_TICS (2)
#define broly_duration(o) ((o)->extravalue1)
#define broly_maxscale(o) ((o)->extravalue2)
static inline fixed_t
get_unit_linear (const mobj_t *x)
{
const tic_t t = (x->tics - BUFFER_TICS);
return t * FRACUNIT / broly_duration(x);
}
mobj_t *
Obj_SpawnBrolyKi
( mobj_t * source,
@ -25,13 +49,10 @@ Obj_SpawnBrolyKi
x->color = source->color;
x->hitlag = 0; // do not copy source hitlag
P_SetScale(x, 64 * mapobjectscale);
x->scalespeed = x->scale / duration;
broly_maxscale(x) = 64 * mapobjectscale;
broly_duration(x) = duration;
// The last tic doesn't actually get rendered so in order
// to show scale = destscale, add one buffer tic.
x->tics = (duration + 1);
x->destscale = 1; // 0 also doesn't work
x->tics = (duration + BUFFER_TICS);
K_ReduceVFX(x, NULL);
@ -39,3 +60,13 @@ Obj_SpawnBrolyKi
return x;
}
void
Obj_BrolyKiThink (mobj_t *x)
{
const fixed_t
t = get_unit_linear(x),
n = Easing_OutSine(t, 0, broly_maxscale(x));
P_InstaScale(x, n);
}

View file

@ -6508,6 +6508,9 @@ static void P_MobjSceneryThink(mobj_t *mobj)
case MT_DRIFTELECTRICSPARK:
mobj->renderflags ^= RF_DONTDRAW;
break;
case MT_BROLY:
Obj_BrolyKiThink(mobj);
break;
case MT_VWREF:
case MT_VWREB:
{