Well, I got a plane. And here I have some code that should check, that when you are flying and you press and then release spacebar. it go's to a landing sequence. And if you are not flying and press and then release spacebar it should go to takeoff sequence, exept that when I press spacebar and then release it, nothing hapens, my plane keeps flying.
Here is my code sofar:
bool Flying = true;
bool Takeoff = false;
bool Landing = false;
void MoveAirplane ( void )
{
dbPositionCamera ( dbObjectPositionX(3),dbObjectPositionY(3),dbObjectPositionZ(3) );
dbRotateCamera ( dbObjectAngleX(3), dbObjectAngleY(3), dbObjectAngleZ(3) );
dbMoveCamera ( -100 );
if ( dbKeyState (57) == 1 && Flying == true )
{
if ( dbKeyState (57) == 0 && Flying == true )
{
Flying = false;
Landing = true;
Takeoff = false;
}
}
else if ( dbKeyState (57) == 1 && Flying == false )
{
if ( dbKeyState (57) == 0 && Flying == false )
{
Flying = false;
Landing = false;
Takeoff = true;
}
}
if ( Flying == true )
{
dbMoveObject ( 3, 2 );
if (dbKeyState (17) == 1) // W
{
float AngleX = dbWrapValue(dbObjectAngleX(3) - 1.4);
dbXRotateObject ( 3, AngleX );
}
if (dbKeyState (30) == 1) // A
{
float AngleZ = 1.3;
dbRollObjectLeft (3,AngleZ );
}
if (dbKeyState (31) == 1) // S
{
float AngleX = dbWrapValue(dbObjectAngleX(3) + 1.4);
dbXRotateObject ( 3, AngleX );
}
if (dbKeyState (32) == 1) // D
{
float AngleZ = 1.3;
dbRollObjectRight(3,AngleZ );
}
if ( dbKeyState (32) == 0 && dbKeyState (30) == 0 )
{
if ( dbObjectAngleZ (3) < -3 ) // D
{
float AngleZ = 1.5;
dbRollObjectLeft (3,AngleZ );
}
else if ( dbObjectAngleZ (3) > 3 ) // A
{
float AngleZ = 1.5;
dbRollObjectRight (3,AngleZ );
}
}
}
}
Already alot of thanks to the persons that can help me solve this problem.
Isocadia.
PS: Another problem: When I'm pressing w, my plane goes down, but when I first press w and then press a, my plane only goes down, how come it is not rolling left and descending at the same time??