Game Development Reference
In-Depth Information
no choice but to use the system UI, such as the standard message box under Win-
dows. It ' s better than nothing.
Initialize Your String Subsystem Early
Initialize your text cache, or whatever you use to store text strings, very early.
You can present any errors about initialization failures in the right language. If
the initialization of the text cache fails, present an error with a number. It
s
easier for foreign language speakers almost anywhere in the world to use the
number to find a solution from a customer service person or a website.
'
Global object pointers are much better than global objects. Singleton objects, such as
the instantiation of the class that handles the audio system or perhaps your applica-
tion object, are naturally global, and if you ' re like me, you hate passing pointers or
references to these objects in every single method call from your entry point to the
lowest-level code. Declare global pointers to these objects, initialize them when you
'
re
good and ready, and free them under your complete control. Here
'
s an example of a
more secure way to initialize:
// Main.cpp
-
initialization using pointers to global objects
//
// A useful macro
#define SAFE_DELETE(p) { if (p) { delete (p); (p)=NULL; } }
DataFiles *gp_DataFiles = NULL;
AudioSystem *gp_AudioSystem = NULL;
VideoSystem *gp_VideoSystem = NULL;
int main(void)
{
gp_DataFiles = new DataFiles();
if ( (NULL==gp_DataFiles)
jj
(!gp_DataFiles->Initialized() ) )
{
printf(
The data files are somehow screwed.
);
return 1;
}
gp_AudioSystem = new AudioSystem();
if ( (NULL==gp_AudioSystem)
jj
(!gp_AudioSystem ->Initialized() ) )
{
printf(
The audio system is somehow screwed.
)
return 1;
}
gp_VideoSystem = new VideoSystem();
if ( (NULL==gp_VideoSystem)
jj
(!gp_VideoSystem ->Initialized() ) )
{
Search WWH ::




Custom Search