So I am currently trying to make the game Asteroids for a class. The problem is, I haven't done any coding for about 3/4ths of a year since the last time I had the class and forgot almost everything I learned. I need to move the ship using thrust/acceleration but also cap it, and have friction so that when the thrust stops, the ship slows down instead of just stopping immediately. I have the basic math down below for rotating and accelerating the ship. I'm quite aware that programming is breaking down the problem down into simple steps, the problem comes here where I do not know where to go next. Any help would be much appreciated.
// Ship's starting position
static double positionX = 500.0;
static double positionY = 500.0;
// Calculate ship heading vectors based on current orientation in Radians
static double orientationInRadians;
static double xVector = Math.Sin(orientationInRadians);
static double yVector = Math.Cos(orientationInRadians);
/*Use Left and Right arrows to rotate
Once vector is found,
calculate position of ship 10 units away from current position along heading vector
scale vector to a unit (length of 1) vector*/
static double magnitude = Math.Sqrt(xVector * xVector + yVector * yVector);
static double unitVectorX = xVector / magnitude;
static double unitVectorY = yVector / magnitude;
/*Now that the vector is one unit long
but still points in the ships current orientation
move ship with positionX and positionY as its current coordinates*/
static double distanceToTravel = 10.0;
double newPositionX = positionX + unitVectorX * distanceToTravel;
double newPositionY = positionY + unitVectorY * distanceToTravel;
/*Remember to track the ship's current position with a double or float
and make distanceToTravel non-constant for acceleration instead of "jumps"*/
EDIT: I forgot to mention, this is the ONLY code I have. So I'm basically stuck with an engine for moving something with nothing to move.