mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 15:21:48 +00:00
- split out the main movement calculation out of P_PlayerInputBoat and used the original code for providing a replacement.
This commit is contained in:
parent
38751d19ac
commit
fca4bdcafb
6 changed files with 94 additions and 72 deletions
|
@ -92,15 +92,15 @@ void displaymasks_r(int snum)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void ShowMotorcycle(double x, double y, int tilenum, int shade, int orientation, int p, int a)
|
||||
void ShowMotorcycle(double x, double y, int tilenum, int shade, int orientation, int p, double a)
|
||||
{
|
||||
hud_drawsprite(x, y, 34816, a, tilenum, shade, p, 2 | orientation);
|
||||
hud_drawsprite(x, y, 34816, int(a), tilenum, shade, p, 2 | orientation);
|
||||
}
|
||||
|
||||
|
||||
void ShowBoat(double x, double y, int tilenum, int shade, int orientation, int p, int a)
|
||||
void ShowBoat(double x, double y, int tilenum, int shade, int orientation, int p, double a)
|
||||
{
|
||||
hud_drawsprite(x, y, 66048, a, tilenum, shade, p, 2 | orientation);
|
||||
hud_drawsprite(x, y, 66048, int(a), tilenum, shade, p, 2 | orientation);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -675,4 +675,82 @@ void hud_input(int snum)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
TURBOTURNTIME = (TICRATE/8) // 7
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// split out of playerinputboat for readability purposes and condensed using ?: operators
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
int boatApplyTurn(player_struct *p, int turnl, int turnr, int bike_turn, double factor)
|
||||
{
|
||||
static int turnheldtime;
|
||||
static int lastcontroltime;
|
||||
|
||||
int tics = totalclock - lastcontroltime;
|
||||
lastcontroltime = totalclock;
|
||||
|
||||
if (p->MotoSpeed)
|
||||
{
|
||||
if (turnl || p->moto_drink < 0)
|
||||
{
|
||||
turnheldtime += tics;
|
||||
if (!p->NotOnWater)
|
||||
{
|
||||
p->TiltStatus -= (float)factor;
|
||||
if (p->TiltStatus < -10)
|
||||
p->TiltStatus = -10;
|
||||
}
|
||||
if (turnheldtime >= TURBOTURNTIME && p->MotoSpeed != 0)
|
||||
{
|
||||
if (p->NotOnWater) return bike_turn ? -6 : -3;
|
||||
else return bike_turn ? -20 : -10;
|
||||
}
|
||||
else if (turnheldtime < TURBOTURNTIME && p->MotoSpeed != 0)
|
||||
{
|
||||
if (p->NotOnWater) return bike_turn ? -2 : -1;
|
||||
else return bike_turn ? -6 : -3;
|
||||
}
|
||||
}
|
||||
else if (turnr || p->moto_drink > 0)
|
||||
{
|
||||
turnheldtime += tics;
|
||||
if (!p->NotOnWater)
|
||||
{
|
||||
p->TiltStatus += (float)factor;
|
||||
if (p->TiltStatus > 10)
|
||||
p->TiltStatus = 10;
|
||||
}
|
||||
if (turnheldtime >= TURBOTURNTIME && p->MotoSpeed != 0)
|
||||
{
|
||||
if (p->NotOnWater) return bike_turn ? 6 : 3;
|
||||
else return bike_turn ? 20 : 10;
|
||||
}
|
||||
else if (turnheldtime < TURBOTURNTIME && p->MotoSpeed != 0)
|
||||
{
|
||||
if (p->NotOnWater) return bike_turn ? 2 : 1;
|
||||
else return bike_turn ? 6 : 3;
|
||||
}
|
||||
}
|
||||
else if (!p->NotOnWater)
|
||||
{
|
||||
turnheldtime = 0;
|
||||
|
||||
if (p->TiltStatus > 0)
|
||||
p->TiltStatus -= (float)factor;
|
||||
else if (p->TiltStatus < 0)
|
||||
p->TiltStatus += (float)factor;
|
||||
|
||||
if (fabs(p->TiltStatus) < 0.025)
|
||||
p->TiltStatus = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -2545,8 +2545,8 @@ void onMotorcycleHit(int snum, int var60)
|
|||
{
|
||||
if (numplayers == 1)
|
||||
{
|
||||
fi.movesprite(var60, sintable[(p->TiltStatus * 20 + p->getang() + 512) & 2047] >> 8,
|
||||
sintable[(p->TiltStatus * 20 + p->getang()) & 2047] >> 8, sprite[var60].zvel, CLIPMASK0);
|
||||
fi.movesprite(var60, sintable[int(p->TiltStatus * 20 + p->getang() + 512) & 2047] >> 8,
|
||||
sintable[int(p->TiltStatus * 20 + p->getang()) & 2047] >> 8, sprite[var60].zvel, CLIPMASK0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2602,8 +2602,8 @@ void onBoatHit(int snum, int var60)
|
|||
{
|
||||
if (numplayers == 1)
|
||||
{
|
||||
fi.movesprite(var60, sintable[(p->TiltStatus * 20 + p->getang() + 512) & 2047] >> 9,
|
||||
sintable[(p->TiltStatus * 20 + p->getang()) & 2047] >> 9, sprite[var60].zvel, CLIPMASK0);
|
||||
fi.movesprite(var60, sintable[int(p->TiltStatus * 20 + p->getang() + 512) & 2047] >> 9,
|
||||
sintable[int(p->TiltStatus * 20 + p->getang()) & 2047] >> 9, sprite[var60].zvel, CLIPMASK0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -540,7 +540,7 @@ void displayrooms(int snum, int smoothratio)
|
|||
else
|
||||
{
|
||||
// The fixed point fuckery at play here means we cannot do the interpolation at full precision.
|
||||
auto oa = p->oq16rotscrnang >> FRACUNIT;
|
||||
auto oa = p->oq16rotscrnang >> FRACBITS;
|
||||
renderSetRollAngle(oa + mulscale16(((p->getrotscrnang() - oa + 1024) & 2047) - 1024, smoothratio));
|
||||
p->oq16rotscrnang = p->q16rotscrnang; // JBF: save it for next time
|
||||
}
|
||||
|
|
|
@ -180,7 +180,8 @@ struct player_struct
|
|||
int drug_timer;
|
||||
int SeaSick;
|
||||
short MamaEnd; // raat609
|
||||
short MotoSpeed, TiltStatus, moto_drink;
|
||||
short MotoSpeed, moto_drink;
|
||||
float TiltStatus;
|
||||
short VBumpNow, VBumpTarget, TurbCount;
|
||||
short drug_stat[3]; // raat5f1..5
|
||||
uint8_t DrugMode, lotag800kill;
|
||||
|
|
|
@ -712,6 +712,8 @@ void P_GetInputMotorcycle(int playerNum)
|
|||
}
|
||||
}
|
||||
|
||||
int boatApplyTurn(player_struct* p, int turnl, int turnr, int bike_turn, double factor);
|
||||
|
||||
void P_GetInputBoat(int playerNum)
|
||||
{
|
||||
auto &thisPlayer = g_player[playerNum];
|
||||
|
@ -813,68 +815,9 @@ void P_GetInputBoat(int playerNum)
|
|||
static int32_t lastInputClock; // MED
|
||||
int32_t const elapsedTics = (int32_t)totalclock - lastInputClock;
|
||||
|
||||
if (pPlayer->MotoSpeed != 0)
|
||||
{
|
||||
if (turnLeft || pPlayer->moto_drink < 0)
|
||||
{
|
||||
turnHeldTime += elapsedTics;
|
||||
if (!pPlayer->NotOnWater)
|
||||
{
|
||||
pPlayer->TiltStatus -= scaleAdjustmentToInterval(1);
|
||||
if (pPlayer->TiltStatus < -10)
|
||||
pPlayer->TiltStatus = -10;
|
||||
if (turnHeldTime >= TURBOTURNTIME)
|
||||
input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 40 : 20)));
|
||||
else
|
||||
input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 12 : 6)));
|
||||
}
|
||||
else
|
||||
if (turnHeldTime >= TURBOTURNTIME)
|
||||
input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 12 : 6)));
|
||||
else
|
||||
input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 4 : 2)));
|
||||
}
|
||||
else if (turnRight || pPlayer->moto_drink > 0)
|
||||
{
|
||||
turnHeldTime += elapsedTics;
|
||||
if (!pPlayer->NotOnWater)
|
||||
{
|
||||
pPlayer->TiltStatus += scaleAdjustmentToInterval(1);
|
||||
if (pPlayer->TiltStatus > 10)
|
||||
pPlayer->TiltStatus = 10;
|
||||
if (turnHeldTime >= TURBOTURNTIME)
|
||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 40 : 20)));
|
||||
else
|
||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 12 : 6)));
|
||||
}
|
||||
else
|
||||
if (turnHeldTime >= TURBOTURNTIME)
|
||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 12 : 6)));
|
||||
else
|
||||
input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turn ? 4 : 2)));
|
||||
}
|
||||
else if (!pPlayer->NotOnWater)
|
||||
{
|
||||
turnHeldTime = 0;
|
||||
|
||||
if (pPlayer->TiltStatus > 0)
|
||||
pPlayer->TiltStatus -= scaleAdjustmentToInterval(1);
|
||||
else if (pPlayer->TiltStatus < 0)
|
||||
pPlayer->TiltStatus += scaleAdjustmentToInterval(1);
|
||||
}
|
||||
}
|
||||
else if (!pPlayer->NotOnWater)
|
||||
{
|
||||
turnHeldTime = 0;
|
||||
|
||||
if (pPlayer->TiltStatus > 0)
|
||||
pPlayer->TiltStatus -= scaleAdjustmentToInterval(1);
|
||||
else if (pPlayer->TiltStatus < 0)
|
||||
pPlayer->TiltStatus += scaleAdjustmentToInterval(1);
|
||||
}
|
||||
|
||||
if (pPlayer->TiltStatus > -0.025 && pPlayer->TiltStatus < 0.025)
|
||||
pPlayer->TiltStatus = 0;
|
||||
// turn is truncated to integer precision to avoid having micro-movement affect the result, which makes a significant difference here.
|
||||
int turnvel = boatApplyTurn(pPlayer, turnLeft, turnRight, turn >> FRACBITS, scaleAdjust);
|
||||
input.q16avel += int(turnvel * scaleAdjust * FRACUNIT);
|
||||
|
||||
input.fvel += pPlayer->MotoSpeed;
|
||||
input.q16avel = fix16_mul(input.q16avel, avelScale);
|
||||
|
|
Loading…
Reference in a new issue