Skip to content

Instantly share code, notes, and snippets.

@jbubriski
Created August 29, 2012 17:40
Show Gist options
  • Save jbubriski/3516037 to your computer and use it in GitHub Desktop.
Save jbubriski/3516037 to your computer and use it in GitHub Desktop.
Ship Acceleration and Velocity
public float Acceleration { get; set; }
public void Update(GameTime gameTime)
{
var additionalVelocity = new Vector2((float)Mat.Cos(Rotation) * Acceleration, (float)Math.Sin(Rotation) * Acceleration);
var newVelocity = CurrentVelocity + additionalVelocity;
if (Math.Abs(newVelocity.DistanceTo(Vector2.Zero)) <= 250)
{
CurrentVelocity = newVelocity;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment