I want to move an object forward, depending on what angle it faces, in this case it’s a tank.
So what I want to do is this:
When I press W, the tank has to move forward.
When I press A or D, it rotates the angle.
So far I’m able to rotate the angle but I have no idea on how to make the tank move forward.
I have tried things like.
if (key.IsKeyDown(Keys.W))
{
TankPos.Y = TankPos.Y - 4;
}
But of course, that only makes it go up, no matter the angle. Any simple solution?
Elaborating on spenders answer, and depending if you are using fixed time step or not, you also need to multiply the delta with the time elapsed since the last frame.
(Milliseconds or Seconds, depending on which measurement you use for your tank speeds.