If you want to do this, you'll need a basic bit of trignomotery. Luckily for you, this is only a 2D game, so almost no thinking is required :)
Anyway: You would need a variable for the rotation angle as well as your velocity. When 'A' is being pressed, you add to the angle, and when 'D' is being pressed, you subtract. Now, onto the trig bit: If you have a triangle, and an angle, imagine this as your rotation and 'a' as your y velocity and 'b' as your x velocity:
Now, we know that 'a' and 'b' are the same, and they will be
_velocity. So we can very easiily find our total velocity now with trigonometry:
1 2 3
|
// (EDIT) _rot is in radians
GetSprite().Move(_velocity * elapsedTime * std::sin(_rot),
_velocity * elapsedTime * std::cos(_rot));
|
Hope this helps!
EDIT:
Of course, you will need to do a couple of other things too, like rotate the sprite, and process bouncing and whatever, but you should be able to work out (Hint: you have the rotation of the object).