Game Development Reference
In-Depth Information
Figure 2.2
A closer look at the application layer.
Imagine what happens when a player mashes the A button on the controller
the
normal control for the emergency brake in my favorite Xbox 360 racing game. The
human view interprets this as a request to hit the emergency brake on my Ferrari and
sends a message to the game logic. The game logic evaluates the request, sets
m_bIsEmergencyBrakeOn to true, and sends a state update back to the human
view. The human view responds to this message by playing a sound effect or maybe
showing something on the screen. Another example is the throttle setting. The con-
troller sends a message to the game view that the right trigger is pressed 82%. The
view interprets this as a command to set the accelerator to 82% and sends a request
to the game logic. The game logic determines that the rear tires have broken loose by
looking at the car, its weight, the tires, the track condition, and other factors. It sends
a message back to the game view that the rear tires are spinning, and the game view
can then respond by playing a sound effect.
You can see that the game controller
'
s thumbstick or button state doesn
'
t affect the
'
game state directly. Instead, the controller
s state is interpreted by the game view and
converted into commands, which are sent to the game logic by an event. The game
logic receives events generated by the view and uses those commands, along with its
physics simulation, to figure out what is happening in the game universe. The state
changes in the game world get sent back to the view, so it can draw polygons, play
sound effects, and rumble the controller.
The game view for the AI is a little different. It will receive the same game state
events received by the human game view, such as which track the race is occurring
on, the weather conditions, and the constantly updated positions, orientations, and
velocity of cars on the track. It will take this information and recalculate what com-
mands to send into the game logic. For example, in response to the
Go
event from
the game logic, the AI might send an
command back to the
game logic. While negotiating a turn, it might send Steer left at 50% to the game
logic.
Accelerator at 100%
Search WWH ::




Custom Search