Improve rotation handling in edge cases

This commit is contained in:
Dean Herbert 2018-07-30 18:50:59 +09:00
parent a39188f762
commit f4cda695e6
1 changed files with 5 additions and 4 deletions

View File

@ -101,17 +101,18 @@ public void UpdateSnakingPosition(Vector2 start, Vector2 end)
break;
}
float aimRotation = MathHelper.RadiansToDegrees(
(float)Math.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
float aimRotation = MathHelper.RadiansToDegrees((float)Math.Atan2(aimRotationVector.Y - Position.Y, aimRotationVector.X - Position.X));
while (Math.Abs(aimRotation - Rotation) > 180)
aimRotation += aimRotation < Rotation ? 360 : -360;
if (!hasRotation || Math.Abs(aimRotation - Rotation) > 180)
if (!hasRotation)
{
Rotation = aimRotation;
hasRotation = true;
}
else
{
Rotation = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 100), Rotation, aimRotation, 0, 600, Easing.OutQuint);
Rotation = Interpolation.ValueAt(MathHelper.Clamp(Clock.ElapsedFrameTime, 0, 100), Rotation, aimRotation, 0, 50, Easing.OutQuint);
}
}
}