mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Apply momentum based squash and stretch to every object
Also netsave.
This commit is contained in:
parent
5b86a70db2
commit
696ca049d8
8 changed files with 60 additions and 45 deletions
|
|
@ -487,7 +487,6 @@ typedef struct player_s
|
|||
|
||||
fixed_t speed; // Player's speed (distance formula of MOMX and MOMY values)
|
||||
fixed_t lastspeed;
|
||||
fixed_t lastmomz;
|
||||
|
||||
INT32 deadtimer; // End game if game over lasts too long
|
||||
tic_t exiting; // Exitlevel timer
|
||||
|
|
|
|||
37
src/k_kart.c
37
src/k_kart.c
|
|
@ -2536,7 +2536,6 @@ void K_KartMoveAnimation(player_t *player)
|
|||
|
||||
// Update lastspeed value -- we use to display slow driving frames instead of fast driving when slowing down.
|
||||
player->lastspeed = player->speed;
|
||||
player->lastmomz = player->mo->momz;
|
||||
}
|
||||
|
||||
static void K_TauntVoiceTimers(player_t *player)
|
||||
|
|
@ -4509,6 +4508,42 @@ void K_DriftDustHandling(mobj_t *spawner)
|
|||
}
|
||||
}
|
||||
|
||||
void K_Squish(mobj_t *mo)
|
||||
{
|
||||
const fixed_t maxstretch = 2*FRACUNIT;
|
||||
const fixed_t factor = 3 * mo->height / 2;
|
||||
const fixed_t threshold = factor / 6;
|
||||
|
||||
const fixed_t old3dspeed = abs(mo->lastmomz);
|
||||
const fixed_t new3dspeed = abs(mo->momz);
|
||||
|
||||
const fixed_t delta = abs(old3dspeed - new3dspeed);
|
||||
|
||||
if (delta > threshold)
|
||||
{
|
||||
mo->spritexscale =
|
||||
FRACUNIT + FixedDiv(delta, factor);
|
||||
|
||||
if (mo->spritexscale > maxstretch)
|
||||
mo->spritexscale = maxstretch;
|
||||
|
||||
if (abs(new3dspeed) > abs(old3dspeed))
|
||||
{
|
||||
mo->spritexscale =
|
||||
FixedDiv(FRACUNIT, mo->spritexscale);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mo->spritexscale -=
|
||||
(mo->spritexscale - FRACUNIT)
|
||||
/ (mo->spritexscale < FRACUNIT ? 8 : 2);
|
||||
}
|
||||
|
||||
mo->spriteyscale =
|
||||
FixedDiv(FRACUNIT, mo->spritexscale);
|
||||
}
|
||||
|
||||
static mobj_t *K_FindLastTrailMobj(player_t *player)
|
||||
{
|
||||
mobj_t *trail;
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ void K_SpawnSparkleTrail(mobj_t *mo);
|
|||
void K_SpawnWipeoutTrail(mobj_t *mo, boolean offroad);
|
||||
void K_SpawnDraftDust(mobj_t *mo);
|
||||
void K_DriftDustHandling(mobj_t *spawner);
|
||||
void K_Squish(mobj_t *mo);
|
||||
mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t mapthing, INT32 defaultDir, INT32 altthrow);
|
||||
void K_PuntMine(mobj_t *mine, mobj_t *punter);
|
||||
void K_DoSneaker(player_t *player, INT32 type);
|
||||
|
|
|
|||
|
|
@ -8616,7 +8616,7 @@ void P_MobjThinker(mobj_t *mobj)
|
|||
return;
|
||||
}
|
||||
|
||||
mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL|MFE_DAMAGEHITLAG);
|
||||
mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL|MFE_DAMAGEHITLAG|MFE_SLOPELAUNCHED);
|
||||
|
||||
tmfloorthing = tmhitthing = NULL;
|
||||
|
||||
|
|
@ -8867,6 +8867,11 @@ void P_MobjThinker(mobj_t *mobj)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(mobj->eflags & MFE_SLOPELAUNCHED))
|
||||
K_Squish(mobj);
|
||||
|
||||
mobj->lastmomz = mobj->momz;
|
||||
}
|
||||
|
||||
// Quick, optimized function for the Rail Rings
|
||||
|
|
|
|||
|
|
@ -249,6 +249,8 @@ typedef enum
|
|||
MFE_JUSTBOUNCEDWALL = 1<<12,
|
||||
// SRB2Kart: In damage hitlag (displays different visual efx)
|
||||
MFE_DAMAGEHITLAG = 1<<13,
|
||||
// Slope physics sent you airborne
|
||||
MFE_SLOPELAUNCHED = 1<<14,
|
||||
// free: to and including 1<<15
|
||||
} mobjeflag_t;
|
||||
|
||||
|
|
@ -360,6 +362,7 @@ typedef struct mobj_s
|
|||
|
||||
fixed_t friction;
|
||||
fixed_t movefactor;
|
||||
fixed_t lastmomz;
|
||||
|
||||
INT32 fuse; // Does something in P_MobjThinker on reaching 0.
|
||||
fixed_t watertop; // top of the water FOF the mobj is in
|
||||
|
|
|
|||
|
|
@ -1534,7 +1534,8 @@ typedef enum
|
|||
MD2_HITLAG = 1<<24,
|
||||
MD2_WAYPOINTCAP = 1<<25,
|
||||
MD2_KITEMCAP = 1<<26,
|
||||
MD2_ITNEXT = 1<<27
|
||||
MD2_ITNEXT = 1<<27,
|
||||
MD2_LASTMOMZ = 1<<28,
|
||||
} mobj_diff2_t;
|
||||
|
||||
typedef enum
|
||||
|
|
@ -1775,6 +1776,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
|
|||
diff2 |= MD2_KITEMCAP;
|
||||
if (mobj->itnext)
|
||||
diff2 |= MD2_ITNEXT;
|
||||
if (mobj->lastmomz)
|
||||
diff2 |= MD2_LASTMOMZ;
|
||||
|
||||
if (diff2 != 0)
|
||||
diff |= MD_MORE;
|
||||
|
|
@ -1968,6 +1971,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
|
|||
{
|
||||
WRITEINT32(save_p, mobj->hitlag);
|
||||
}
|
||||
if (diff2 & MD2_LASTMOMZ)
|
||||
{
|
||||
WRITEINT32(save_p, mobj->lastmomz);
|
||||
}
|
||||
|
||||
WRITEUINT32(save_p, mobj->mobjnum);
|
||||
}
|
||||
|
|
@ -3062,6 +3069,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker)
|
|||
{
|
||||
mobj->hitlag = READINT32(save_p);
|
||||
}
|
||||
if (diff2 & MD2_LASTMOMZ)
|
||||
{
|
||||
mobj->lastmomz = READINT32(save_p);
|
||||
}
|
||||
|
||||
if (diff & MD_REDFLAG)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -844,6 +844,8 @@ void P_SlopeLaunch(mobj_t *mo)
|
|||
mo->momy = slopemom.y;
|
||||
mo->momz = slopemom.z;
|
||||
#endif
|
||||
|
||||
mo->eflags |= MFE_SLOPELAUNCHED;
|
||||
}
|
||||
|
||||
//CONS_Printf("Launched off of slope.\n");
|
||||
|
|
|
|||
41
src/p_user.c
41
src/p_user.c
|
|
@ -1658,42 +1658,6 @@ static void P_DoBubbleBreath(player_t *player)
|
|||
}
|
||||
}
|
||||
|
||||
static void squish(player_t *player)
|
||||
{
|
||||
const fixed_t maxstretch = 2*FRACUNIT;
|
||||
const fixed_t factor = 3 * player->mo->height / 2;
|
||||
const fixed_t threshold = factor / 6;
|
||||
|
||||
const fixed_t old3dspeed = abs(player->lastmomz);
|
||||
const fixed_t new3dspeed = abs(player->mo->momz);
|
||||
|
||||
const fixed_t delta = abs(old3dspeed - new3dspeed);
|
||||
|
||||
if (delta > threshold)
|
||||
{
|
||||
player->mo->spritexscale =
|
||||
FRACUNIT + FixedDiv(delta, factor);
|
||||
|
||||
if (player->mo->spritexscale > maxstretch)
|
||||
player->mo->spritexscale = maxstretch;
|
||||
|
||||
if (abs(new3dspeed) > abs(old3dspeed))
|
||||
{
|
||||
player->mo->spritexscale =
|
||||
FixedDiv(FRACUNIT, player->mo->spritexscale);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player->mo->spritexscale -=
|
||||
(player->mo->spritexscale - FRACUNIT)
|
||||
/ (player->mo->spritexscale < FRACUNIT ? 8 : 2);
|
||||
}
|
||||
|
||||
player->mo->spriteyscale =
|
||||
FixedDiv(FRACUNIT, player->mo->spritexscale);
|
||||
}
|
||||
|
||||
//#define OLD_MOVEMENT_CODE 1
|
||||
static void P_3dMovement(player_t *player)
|
||||
{
|
||||
|
|
@ -1890,11 +1854,6 @@ static void P_3dMovement(player_t *player)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!player->powers[pw_justlaunched])
|
||||
{
|
||||
squish(player);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue