Game Development Reference
In-Depth Information
Most operating systems have a way to dynamically swap code in and out of memory
at runtime. This is critical for conserving valuable memory space or replacing a sub-
system entirely. You might use a DLL to swap a DirectX for an OpenGL renderer, for
example.
Today
s multicore desktops and consoles make multithreaded and multicore pro-
gramming a must. I actually remember a time when games didn
'
instead everything ran in a single execution path. It was easier in some ways, but
harder in others. Threads are used for audio streaming data, AI, and if you are clever,
even physics. I ' ve read in other places that shall remain nameless that suggest you
can use threads for everything. Don
'
t use threads
t believe this for a minute; if every subsystem
used separate threads, it could be extremely difficult to manage thread synchroniza-
tion, and I guarantee the system would be challenging to debug.
Network communications is another service provided by the operating system. This
network code will generally provide your game with a way to make a network con-
nection with another computer and a way to read and write data from the network
stream. The definition of what actually gets sent and how received data is interpreted
is actually coded in the game view and game logic layer. I
'
'
ll talk more about that
shortly.
The last group in the application layer is responsible for your game
'
s life cycle: ini-
tialization, the main loop, and shutdown. I ' ve also included in this group your core
libraries that standardize basic data structures and templates, as well as your script
interpreter.
Initialization can be something of a nightmare. Many game subsystems have compli-
cated interrelations, and they tend to depend on one another. We
'
ll discuss details of
the initialization sequence in Chapter 5.
Most games use scripting languages. Whether it is UnrealScript, Python, Lua, or
something a game team creates from scratch, these systems and the scripts they
run are critical components for today
'
s commercial game development. You
'
ll learn
more about scripting languages, and Lua in particular, in Chapter 12,
Scripting
with Lua.
Game Logic
The game logic (see Figure 2.3) is the heart and soul of your game. It defines the
game universe, what things are in the universe, and how they interact. It also defines
how the game state can be changed by external stimulus, such as a human player
pressing a gamepad key or an AI process taking action to kill you. Let
'
s take a closer
look at all of the components of the game logic system.
 
 
Search WWH ::




Custom Search