Guest User

Moving in direction

a guest
Sep 2nd, 2011
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. double x;
  2. double y;
  3. double angle;    // in radians, if you want degrees: convert to radians before use
  4. const double movementSpeedPerSec = 10.0;
  5. ...
  6. Update(GameTime gameTime)
  7. {
  8.     x += movementSpeedPerSec * cos(angle) * gameTime.ElapsedGameTime.TotalSeconds;
  9.         y += movementSpeedPerSec * -sin(angle) * gameTime.ElapsedGameTime.TotalSeconds;
  10. }
RAW Paste Data