I am working on a 2D ship that will fly around in space (for now, no friction or gravity). The controls are similar to the game Asteroids. My problem is that I am having trouble connecting some variables to real life applications.
For example, if I'm defining the ships velocity, which in real physics is V=distance traveled (or change in position)/time. Should velocity be a Vector2 or just a float (or int). It's how far an object moves so I would think it to be just a single integer or number but then again, your moving on an X and Y axis so shouldn't there be two velocities? One for the X and another for the Y? The velocity being a vector2 actually works really well but when I'm doing other formulas, which are floats or ints, that require velocity I run into issues because I don't have a single number then.
Another issue i'm having trouble grasping is the direction. My code for the direction is:
shipVariables.shipDirection = new Vector2((float)Math.Sin(shipVariables.shipRotation), -(float)Math.Cos(shipVariables.shipRotation));
Which works but it will immediately turns the ship if you rotate the object while moving "forward". My most successful approach to this method was doing this:
shipVariables.shipDirection += new Vector2((float)Math.Sin(shipVariables.shipRotation), -(float)Math.Cos(shipVariables.shipRotation));
The effect I like is that instead of just turning, it essentially has to overcome the previous direction to move to the next. The part I don't like is that it gains speed way to much and it's supposed to just be a direction, not a direction and magnitude.
If I have the velocity and I can get the direction, I will be able to calculate everything else with other formulas that I know (momentum, acceleration, etc...).
Any tips to lead me in the right directions would be great, thanks.