Game Development Reference
In-Depth Information
// is important because some classes may dynamically
// allocate memory in globally constructed objects.
//
//_CrtDumpMemoryLeaks(); // Reports leaks to stderr
// Destroy the logging system at the last possible moment
Logger::Destroy();
return g_pApp->GetExitCode();
}
These calls to the DXUTSetCallbackEtc functions allow the DirectX Framework to
notify the application about device changes, user input, and Windows messages. You
should always handle the callbacks for device reset/lost, or your game won
'
t be able
to withstand things like fast user task switching under Windows.
The calls to the CrtDumpMemory functions set up your game to detect memory
leaks, something discussed at length in Chapter 23,
Player options are stored in an XML file and are loaded into the GameOptions class.
This class can store whatever you like, but in this example it simply stores the desired
screen width and height of the game window. Extensions of this class could store
sound volume settings, how many players the game supports, and other important
data.
g_pApp points to a global object that stores the game ' s application layer. Let ' s take a
look at the base class, GameCodeApp .
Debugging Your Game.
The Application Layer: GameCodeApp
The game
'
-
specific tasks, including inter-
facing with the hardware and operating system, handling the application life cycle
including initialization, managing access to localized strings, and initializing the game
logic. This class is meant to be inherited by a game-specific application class that will
extend it and define some game-specific things, such as title, but also implementations
for creating the game logic and game views and loading the initial state of the game.
The class acts as a container for other important members that manage the applica-
tion layer:
s application layer handles operating system
n A handle to the text resource, which is initialized with an XML file. It contains
all of the user-presented strings, such as
Do you want to quit?,
so the game
can easily be localized into other languages.
n The game logic implementation.
n A data structure that holds game options, usually read from an XML file.
 
 
Search WWH ::




Custom Search