mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +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);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// 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.
|
||||
|
@ -170,9 +193,6 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn
|
|||
}
|
||||
else
|
||||
{
|
||||
static double turnheldtime;
|
||||
int const turnheldamt = 120 / GameTicRate;
|
||||
double const turboturntime = 590. / GameTicRate;
|
||||
double turnamount = hidspeed * turnscale;
|
||||
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))
|
||||
{
|
||||
turnheldtime += scaleAdjust * turnheldamt;
|
||||
currInput->avel -= scaleAdjust * (turnheldtime >= turboturntime ? turnamount : preambleturn);
|
||||
updateTurnHeldAmt(scaleAdjust);
|
||||
currInput->avel -= scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn);
|
||||
}
|
||||
else if (buttonMap.ButtonDown(gamefunc_Turn_Right) || (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !allowstrafe))
|
||||
{
|
||||
turnheldtime += scaleAdjust * turnheldamt;
|
||||
currInput->avel += scaleAdjust * (turnheldtime >= turboturntime ? turnamount : preambleturn);
|
||||
updateTurnHeldAmt(scaleAdjust);
|
||||
currInput->avel += scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn);
|
||||
}
|
||||
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, 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 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);
|
||||
|
|
Loading…
Reference in a new issue