As far as I know I am yes. Here's my main loop:
// the main entry point for the application is this function
void DarkGDK()
{
/**************************************************************************
* PreCondition: Program Load
* PostCondition: The Program will exit and resources will be freed
* Description: This is the main entry function that encompasses the
* game loop and any work that need be done outside of it.
* Algorithm: Set up the initial screen and variables
* Enter Game Loop
* During game loop, check input and update the screen
* Exit the program
**************************************************************************/
//Seed the random number generator
dbRandomize(dbTimer());
//Set up the initial screen
SetUpMainMenu();
// our main loop
while(LoopGDK())
{
//Check input
CheckInput();
//Update the terrain
if(Position == Engine && Scenario != Space)
dbUpdateTerrain();
//Take care of non-player events
if(Position == Engine)
AutomatedEvents();
// update the screen
dbSync();
}
// return back to windows
return;
}
The statements in the ifs are enumerated types I made to clear things up. AutomatedEvents() deals with gravity, keeping the Listener thingy with the player, etc. There is no screen refresh code in it. CheckInput() simply has a switch statement in it to determine what keys to look for based on what screen we're on. In the case of the game engine it branches to the following
void EngineInput()
{
/**************************************************************************
* PreCondition: The game scenario has been loaded correctly
* PostCondition: The appropriate camera action will be applied
* Description: This functions handles the input for the game engine
* Algorithm: If "Left Arrow" is pressed, Strafe Left
* If "Right Arrow" is pressed, Strafe Right
* If "Up Arrow" is pressed, move forward
* If "Down Arrow" is pressed, move backwards
* Establish where the mouse moved to
* Rotate the camera based on the mouse movement
**************************************************************************/
//If the Escape Key was pressed
if(dbEscapeKey())
{
int count = 1;
//Clean up and return to the title screen
dbCLS();
//Delete the terrain, skybox, and players
for(count = 1; count < 5; count++)
{
if(dbObjectExist(count))
dbDeleteObject(count);
}
//Delete the in-game objects
while(dbObjectExist(count))
{
dbDeleteObject(count);
count++;
}
count = 1;
//Delete the sound effects
while(dbSoundExist(count))
{
dbDeleteSound(count);
}
//Display the title screen
LoadTitleScreen();
dbEnableEscapeKey();
dbSync();
return;
}
}
So, this just does cleanup, deleting everything to free up memory. My Terrain is object 1, Skybox 2, and the 2 players are 3 & 4. All the other objects are 5+. After it does that clean-up, here's what LoadTitle Screen() does:
void LoadTitleScreen()
{
/**************************************************************************
* PreCondition: The program is loading or has come from any of the menus
* PostCondition: The title screen will be displayed
* Description: This function draws the Title Screen
* Algorithm: If the Options screen occupies the bitmap slot, delete it
* Clear the Screen
* Load the Title Screen base bitmap
* Copy the bitmap to the screen
* Free up the memory used by the bitmap
* Set the program position to the title screen
* Give the program focus back to the screen
**************************************************************************/
//If we came from the Options Screen, free up memory
if(dbBitmapExist(1))
dbDeleteBitmap(1);
//If we came from the game engine, change the music
if (Position == Engine)
{
dbStopMusic(1);
dbDeleteMusic(1);
dbLoadMusic(".\\Music\\16 At Dawn.mp3",1);
dbLoopMusic(1);
}
//Clear the Screen
dbCLS();
//Load the Title Screen then free up resources
dbLoadBitmap(".\\Images\\TitleScreen640x480.bmp",1);
dbCopyBitmap(1,0);
dbDeleteBitmap(1);
//Keep track of where we are in the program
Position = Main;
dbSetCurrentBitmap(0);
return;
}
I realize I have an extra dbCLS() in there, but it shouldn't matter as it is placed before the screen drawings. By the time this function is done executing, half of the main loop no longer runs (i.e. all it does is CheckInput() and dbSync() like it's supposed to). When it refreshes I get a split second viewing of my title screen, then the Blue void of an empty 3D environment (not the Black void of dbCLS()). Hence my question in my first post. Thank you again in advance!
"...The Protoss do not run from their enemies. Aiur is our homeworld, it is here that we shall make our stand!" -Aldaris