public override void Update(float dt) { base.Update(dt); // Slow Down if (DefaultVelocityApplication) { if (Velocity.X != 0.0f && !IsMovingHorizontally()) { Velocity.X = Utils.StepTo(Velocity.X, 0.0f, Friction * dt); } else if (Velocity.X > SpeedMax) { Velocity.X = Utils.StepTo(Velocity.X, SpeedMax, Friction * dt); } else if (Velocity.X < -SpeedMax) { Velocity.X = Utils.StepTo(Velocity.X, -SpeedMax, Friction * dt); } if (Velocity.Y != 0.0f && !IsMovingVertically()) { Velocity.Y = Utils.StepTo(Velocity.Y, 0.0f, Friction * dt); } else if (Velocity.Y > SpeedMax) { Velocity.Y = Utils.StepTo(Velocity.Y, SpeedMax, Friction * dt); } else if (Velocity.X < -SpeedMax) { Velocity.Y = Utils.StepTo(Velocity.Y, -SpeedMax, Friction * dt); } } else { if (Velocity.X != 0 || Velocity.Y != 0) { Velocity.X = Utils.StepTo(Velocity.X, 0.0f, Friction * dt); Velocity.Y = Utils.StepTo(Velocity.Y, 0.0f, Friction * dt); } else { if (!IsMoving()) { MoveAngleVelocity = Utils.StepTo(MoveAngleVelocity, 0, Friction * dt); } else if (MoveAngleVelocity > SpeedMax) { MoveAngleVelocity = Utils.StepTo(MoveAngleVelocity, SpeedMax, Friction * dt); } } } // Apply Velocity if (DefaultVelocityApplication || Velocity.X != 0 || Velocity.Y != 0) { Move(Velocity.X * dt, Velocity.Y * dt); } else { Move((float)Math.Cos(MoveAngle) * (MoveAngleVelocity * dt), (float)Math.Sin(MoveAngle) * (MoveAngleVelocity * dt)); } }