Yes I already know that, I do have them there and did have this working before I had added the two 'while' statements to add in the Shift function. But that just hanged there when i ran it. So, now I changed the two 'while' statements to 'if' statements shown below, and it works now. But why won't this work with two 'while' statements?
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple 3D project that uses Dark GDK
// it can be used as a starting point in making your own 3D games
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
// in this application we are going to create some 3D objects
// and position them on screen
// when starting a Dark GDK program it is useful to set global
// application properties, we begin by turning the sync rate on,
// this means we control when the screen is updated, we also set
// the maximum rate to 60 which means the maximum frame rate will
// be set at 60 frames per second
dbSyncOn ( );
dbSyncRate ( 60 );
dbLoadObject("H-Small Car Red-Move.x", 1);
dbLoadObject("H-Small Car Red-Move.x", 2);
dbPositionObject(2, 5, 0, 3);
dbPositionObject(1, 10, 0, 3);
dbLoopObject(2);
dbLoopObject(1);
dbSetObjectSpeed(1, 500);
dbSetObjectSpeed(2, 500);
float ShiftKey;
// move our camera back so we can view the objects
dbPositionCamera ( 7.5, 0, -3 );
// now we come to our main loop, we call LoopGDK so some internal
// work can be carried out by the GDK
while ( LoopGDK ( ) )
{
ShiftKey = dbWrapValue(dbShiftKey());
dbText(0, 300, "Press and hold the Shift Key to move the har on the left");
dbText(0, 315, "Press Space to reset the position of either object");
if(ShiftKey == 1)
{
dbText(0, 70, "The Shift Key is being pressed");
if(dbSpaceKey()){
dbDeleteObject(2);
dbLoadObject("H-Small Car Red-Move.x", 2);
dbPositionObject(2, 5, 0, 3);
dbLoopObject(2);
dbSetObjectSpeed(2, 500);
dbPositionCamera ( 7.5, 0, -3 );
dbSync();
}
if(dbLeftKey()){
dbTurnObjectRight(2, 3);
dbText(0, 0, "The left key is being pressed");
}
if(dbRightKey()){
dbTurnObjectLeft(2, 3);
dbText(0, 15, "The right key is being pressed");
}
if(dbUpKey()){
dbPitchObjectDown(2, 3);
dbText(0, 30, "The up key is being pressed");
}
if(dbDownKey()){
dbPitchObjectUp(2, 3);
dbText(0, 45, "The down key is being pressed");
}
}
if(ShiftKey == 0)
{
if(dbSpaceKey()){
dbDeleteObject(1);
dbLoadObject("H-Small Car Red-Move.x", 1);
dbPositionObject(1, 10, 0, 3);
dbLoopObject(1);
dbSetObjectSpeed(1, 500);
dbPositionCamera ( 7.5, 0, -3 );
dbSync();
}
if(dbDownKey()){
dbPitchObjectUp(1, 3);
dbText(0, 45, "The down key is being pressed");
}
if(dbUpKey()){
dbPitchObjectDown(1, 3);
dbText(0, 30, "The up key is being pressed");
}
if(dbRightKey()){
dbTurnObjectLeft(1, 3);
dbText(0, 15, "The right key is being pressed");
}
if(dbLeftKey()){
dbTurnObjectRight(1, 3);
dbText(0, 0, "The left key is being pressed");
}
}
// here we make a call to update the contents of the screen
dbSync ( );
}
// before quitting delete our objects
for ( int i = 1; i < 50; i++ )
dbDeleteObject ( i );
// and now everything is ready to return back to Windows
return;
}