mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-15 20:20:54 +00:00
- gameinput.cpp: Break out processMovement()
's turnheldamt calculations into functions.
This commit is contained in:
parent
a1dd36ffee
commit
36c25ee2a0
2 changed files with 32 additions and 8 deletions
|
@ -91,6 +91,29 @@ lookangle getincanglebam(binangle a, binangle na)
|
||||||
return bamlook(newa-cura);
|
return bamlook(newa-cura);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Functions for determining whether its turbo turn time (turn key held for a number of tics).
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static double turnheldtime;
|
||||||
|
|
||||||
|
void updateTurnHeldAmt(double const scaleAdjust)
|
||||||
|
{
|
||||||
|
turnheldtime += scaleAdjust * (120. / GameTicRate);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool const isTurboTurnTime()
|
||||||
|
{
|
||||||
|
return turnheldtime >= 590. / GameTicRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetTurnHeldAmt()
|
||||||
|
{
|
||||||
|
turnheldtime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Player's movement function, called from game's ticker or from gi->GetInput() as required.
|
// Player's movement function, called from game's ticker or from gi->GetInput() as required.
|
||||||
|
@ -170,9 +193,6 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
static double turnheldtime;
|
|
||||||
int const turnheldamt = 120 / GameTicRate;
|
|
||||||
double const turboturntime = 590. / GameTicRate;
|
|
||||||
double turnamount = hidspeed * turnscale;
|
double turnamount = hidspeed * turnscale;
|
||||||
double preambleturn = turnamount * (750. / 2776.);
|
double preambleturn = turnamount * (750. / 2776.);
|
||||||
|
|
||||||
|
@ -184,17 +204,17 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
|
||||||
|
|
||||||
if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !allowstrafe))
|
if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !allowstrafe))
|
||||||
{
|
{
|
||||||
turnheldtime += scaleAdjust * turnheldamt;
|
updateTurnHeldAmt(scaleAdjust);
|
||||||
currInput->avel -= scaleAdjust * (turnheldtime >= turboturntime ? turnamount : preambleturn);
|
currInput->avel -= scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn);
|
||||||
}
|
}
|
||||||
else if (buttonMap.ButtonDown(gamefunc_Turn_Right) || (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !allowstrafe))
|
else if (buttonMap.ButtonDown(gamefunc_Turn_Right) || (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !allowstrafe))
|
||||||
{
|
{
|
||||||
turnheldtime += scaleAdjust * turnheldamt;
|
updateTurnHeldAmt(scaleAdjust);
|
||||||
currInput->avel += scaleAdjust * (turnheldtime >= turboturntime ? turnamount : preambleturn);
|
currInput->avel += scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
turnheldtime = 0;
|
resetTurnHeldAmt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,6 +269,10 @@ class FSerializer;
|
||||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def);
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerAngle& w, PlayerAngle* def);
|
||||||
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def);
|
FSerializer& Serialize(FSerializer& arc, const char* keyname, PlayerHorizon& w, PlayerHorizon* def);
|
||||||
|
|
||||||
|
|
||||||
|
void updateTurnHeldAmt(double const scaleAdjust);
|
||||||
|
bool const isTurboTurnTime();
|
||||||
|
void resetTurnHeldAmt();
|
||||||
void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt = 0, bool const allowstrafe = true, double const turnscale = 1);
|
void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlInfo* const hidInput, double const scaleAdjust, int const drink_amt = 0, bool const allowstrafe = true, double const turnscale = 1);
|
||||||
void sethorizon(fixedhoriz* horiz, float const horz, ESyncBits* actions, double const scaleAdjust = 1);
|
void sethorizon(fixedhoriz* horiz, float const horz, ESyncBits* actions, double const scaleAdjust = 1);
|
||||||
void applylook(PlayerAngle* angle, float const avel, ESyncBits* actions, double const scaleAdjust = 1);
|
void applylook(PlayerAngle* angle, float const avel, ESyncBits* actions, double const scaleAdjust = 1);
|
||||||
|
|
Loading…
Reference in a new issue