Okay, I just tested your code, and it works as it should.
But I think i know where you get confused.
360 or 0 degrees (Start position) is horizontal facing right like this arrow -->
or said in another way, if your ship image is facing north, you should rotate it 90 degrees so it faces east in the image file.
Secondly, as mentioned in my post, this is an asteroids like movement, the longer you hold UP, the faster the ship will go.
look at this code part:
if (m_Key.isKeyPressed(Keyboard().Up)) {
m_xVel += (cos(SSpaceship.getRotation() / 180 * 3.1415)) * m_accel;
m_yVel += (sin(SSpaceship.getRotation() / 180 * 3.1415)) * m_accel;
}
SSpaceship.setPosition(SSpaceship.getPosition().x + m_xVel, SSpaceship.getPosition().y + m_yVel);
each time the UP key is pressed, m_xVel and m_yVel is changed.
what happens from the start is this,
-the ship is standing still (m_xVel = 0 and m_yVel = 0) and is rotated 360 degrees.
- UP is pressed, and because of this, the system adds a value to m_xVel and m_yVel (that is the cos and sin code up there) for simplicitys sake, lets say they change to m_xVel = 1, and m_yVel = 0;
-Then m_xVel and m_yVel is added to the ships current position. moving the ship på 1 on the X axis.
-Each update from now on, m_xVel and m_yVel will be the same, and will be added to the ships position, moving it at 1 per update.
-IF UP is pressed again, m_xVel and m_yVel will again get a new value, this value will be added to the old value.
so if whe have not rotated, the new values will be m_xVel = 2, and m_yVel = 0;
-The ship will now be updated and moved twice as fast in the X direction (2 instead of 1)
-IF we then rotate 90 degrees clock vice (the ship facing down) and press UP again. the m_xVel and m_yVel will be changed again, but this time, it would be yVel that gets 1 added to it.
so the nev values are now m_Xvel = 2, and m_yVel = 1.
-The ship is now updated, and moves +2 X and +1 Y (or East-South-East if you will)
Things you should try to make it more easy for yourself to see.
Try to change the value of m_accel to 0.01 or even 0.1.
After the if Key pressed but before SSpaceship.setPosition
Try and add:
m_xVel = m_xVel * 0.99;
m_yVel = m_yVel * 0.99;
This will "Stop" the space ship after some time.
See what happens if you write * 0.5 or * 0.999 instead...
Try to rotate your image in all directions in the editor.
What you should notes is that ite does not effect the code at all, just the "looks"
After SSpaceship.setPosition
try to add:
if (SSpaceship.getPosition().x > 800) SSpaceship.setPosition(0, SSpaceship.getPosition().y);
else if (SSpaceship.getPosition().x < 0) SSpaceship.setPosition(800, SSpaceship.getPosition().y);
if (SSpaceship.getPosition().y > 600) SSpaceship.setPosition(SSpaceship.getPosition().x, 0);
else if (SSpaceship.getPosition().y < 0) SSpaceship.setPosition(SSpaceship.getPosition().x, 600);
This will keep the space ship looping inside the window.
Edit, lastly, I notes that you have two values you never use, int x and int y.
and that you have made a definition of PI.
If you look at your code, there is a place where an approximation of PI is used, if you wish, you could just as well go ahead and and exchange that approximation for your own PI, that would both be more correct mathematical, but also more easy to write in the future.