Game Development Reference
In-Depth Information
Make It So, Number 1!
One day, while working on a Sims project as an AI programmer, the lead
engineer came up to me with some AI tasks related to a new object the
designers wanted to get into the game. They wanted special Sim behavior
for this object. After explaining the designs, he guessed that it would take
a couple of weeks to implement. I smiled and shook my head.
It
'
ll take
two or three days, tops.
s the difference between good architecture
and bad architecture. Good architecture is flexible and easy to change.
That
'
Application Layer
The contents of the application layer are divided further into different areas that deal
with devices, the operating system, and your game ' s lifetime (refer to Figure 2.2).
Reading Input
Games have an amazing variety of user input devices: keyboard, mouse, gamepad,
joystick, dance pad, steering wheel, cameras, accelerometers, GPS, and my personal
favorite, the guitar. Reading these devices is almost always completely dependent on
calls to the operating system and device drivers. The state of these devices should
always be translated into game commands. Some of these commands might be sent
back to the game logic, such as
while others might be handled by the
game view, such as show me my inventory. Either way, you ' ll likely write an entire
subsystem to read these devices and interpret them as commands.
This same system should also be configurable. I play console shooters with an
inverted Y-axis, but many people like it the other way around, even though I
fire missile,
ll
never understand why. If you have a system that reads devices as input and sends
game commands as output, you can create the system to read a configuration file to
match controls with commands. Then all you have to do is modify this data file, and
you ' ll have completely configurable controls.
One thing is critical: You can
'
t simply change the game state directly when you read
user input. Every bit of game sample code out there does this; you can see where
games make direct changes to data simply because the W key was pressed. This is a
vastly inflexible system and will haunt you later, I guarantee it.
'
File Systems and Resource Caching
File systems read from and write data to storage systems such as DVD-ROM, hard
disk, and SD cards. Code in this subsystem will generally be responsible for manag-
ing game resource files and loading and saving the game state. Managing resource
 
 
 
 
Search WWH ::




Custom Search