Hy, my name is viKKmaN.
After 5 days of continous reading the dark gdk tutorials + documentation i managed to get to this project:
- 2D Space Game
- Implemented 0 Gravity Myself
- Ship Moving Forward
- Ship Turning Left / Right
My problem is with calculating the velocity after spinning the ship.
EXAMPLE OF WHAT HAPPENS:

EXAMPLE OF WHAT I WISH TO ACHIEVE:

MY
while(LoopGDK()) Contents:
CODE
float PosX = 0, PosY = 0, VelocityX = 0, VelocityY = 0, ShipAngle = 0, ShipAngleR = 0;
dbLoadImage("ship.bmp", 1);
dbSprite(2, PosX, PosY, 1);
while(LoopGDK())
{
if(dbEscapeKey())
break;
if(dbSpaceKey())
{
VelocityX = 0;
VelocityY = 0;
}
if(dbUpKey())
{
ShipAngleR = ShipAngle;
if(VelocityX > -2)
{
VelocityX -= Speed/100;
}
if(VelocityY > -2)
{
VelocityY -= Speed/100;
}
}
if(dbRightKey())
{
ShipAngle += Turning/10;
if(ShipAngle > 360 || ShipAngle < -360)
ShipAngle = 0;
}
if(dbLeftKey())
{
ShipAngle -= Turning/10;
if(ShipAngle > 360 || ShipAngle < -360)
ShipAngle = 0;
}
PosX += cos((ShipAngleR+90)*(PI/180))*(VelocityX);
PosY += sin((ShipAngleR+90)*(PI/180))*(VelocityY);
dbSprite(2, PosX, PosY, 2);
dbOffsetSprite(2, dbSpriteWidth(2)/2, dbSpriteHeight(2)/2);
dbRotateSprite(2, ShipAngle);
dbSync();
}
This post has been edited by vikkman: 30 Oct, 2009 - 08:57 AM