mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Trigonometry
if not going in the pure speed of the max speed, go with them purified direction into the max speed clamped to max speed, if you don't understand then disregard the previous xD
This commit is contained in:
parent
85df8a047d
commit
4a2a900b6e
|
@ -950,7 +950,8 @@ void CCharacter::HandleTiles(int Index)
|
|||
)
|
||||
m_Core.m_Pos = m_PrevPos;
|
||||
TempVel += Direction * Force;
|
||||
MaxVel = Direction*(MaxSpeed/5);
|
||||
MaxVel.x = clamp((MaxSpeed/5)/Direction.x,-(float)(MaxSpeed/5),(float)(MaxSpeed/5));
|
||||
MaxVel.y = clamp((MaxSpeed/5)/Direction.y,-(float)(MaxSpeed/5),(float)(MaxSpeed/5));
|
||||
if(MaxSpeed && (fabs(Direction.x) > 0.000001) && (TempVel.x > MaxVel.x && MaxVel.x > 0 || TempVel.x < MaxVel.x && MaxVel.x < 0))
|
||||
TempVel.x = MaxVel.x;
|
||||
if(MaxSpeed && (fabs(Direction.y) > 0.000001) && (TempVel.y > MaxVel.y && MaxVel.y > 0 || TempVel.y < MaxVel.y && MaxVel.y < 0))
|
||||
|
|
Loading…
Reference in a new issue