All pastes #759903 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-11-03 16:44 UTC
rendered paste body
// assume mMomentum is a field in the class


Keyboard keyboard = InputManager.Keyboard;

if(keyboard.KeyDown(Keys.Up))
{
   mMomentum += TimeManager.SecondDifference;
}
if(keyboard.KeyDown(Keys.Down))
{
   mMomentum -= TimeManager.SecondDifference;
}

RotationZVelocity = 0;

if(keyboard.KeyDown(Keys.Left))
{
   RotationZVelocity = 1;
}
else if(keyboard.KeyDown(Keys.Right))
{
   RotationZVelocity = -1;
}

// We know the momentum and we know the angle:
XVelocity = (float)Math.Cos(RotationZ) * mMomentum;
YVelocity = (float)Math.Sin(RotationZ) * mMomentum;