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:
GreYFoXGTi 2010-10-30 23:35:39 +02:00
parent 85df8a047d
commit 4a2a900b6e

View file

@ -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))