Game Development Reference
In-Depth Information
Chapter 5
Game Initialization and
Shutdown
There are a million little details about writing games that no one talks about. Lots of
topics and websites can teach you how to draw textured polygons in Direct3D. But
when it comes to figuring out your initialization sequence, you
ll find little discussion.
Most programmers hack something together over time that eventually turns into a
horrible mess.
I
'
ve written this chapter to show you the ins and outs of the entire initialization and
shutdown sequence. As you check out the code in this chapter, keep in mind that
every game is different and may require a different initialization sequence. Hopefully,
you
'
ll gain an understanding of the approach presented here and be able to adapt it
to your particular situation. Truly elegant solutions and algorithms rarely just fall out
of the sky. They usually come to you after seeing some code that is close to what you
need, and you push it the rest of the way yourself.
Every piece of software, including games, has initialization, the core or main loop,
and shutdown. Initialization prepares your canvas for painting pixels. The main
loop accepts and translates user input, changes the game state, and renders the
game state until the loop is broken. This loop is broken by a user quitting the game
or some other kind of failure. The cleanup code releases key system resources, closes
files, and exits back to the operating system.
This chapter deals with initialization and shutdown. Chapter 7,
'
Controlling the
Main Loop,
will dig a little deeper and show you how to control the main loop of
your game.
129
 
 
 
Search WWH ::




Custom Search