Game Development Reference
In-Depth Information
Game Events
You
ve already seen most of the events that will be fired during a highly addictive ses-
sion of Teapot Wars. When objects collide, for example, the physics system sends a col-
lision event just like the one you saw in Chapter 17,
'
There are five new events that are specific to Teapot Wars: EvtData_Fire_Weapon ,
EvtData_Thrust , EvtData_Steer, EvtData_Gameplay_UI_Update ,and Evt
Data_SetControlledActor . Each of these events inherits from ScriptEvent and
is exposed to Lua using the techniques you learned in Chapter 12,
Collision and Simple Physics.
Scripting with Lua.
You
events are trig-
gered from the TeapotController event previously in this chapter. The other
two events are triggered from script and handled by the TeapotWarsHumanView
class. The Set Controlled Actor event is sent during initialization to tell the view
which actor is the controlled actor. The
'
ve already seen how the
Fire Weapon,
”“
Thrust,
and
Steer
event is sent when-
ever the gameplay code needs to update the text at the top of the screen.
There
Gameplay UI Update
'
s nothing new or special about these events; they work exactly like all the other
events you ' ve seen. You can find them in Dev/Source/TeapotWars/TeapotEvents.h.
Gameplay
The vast majority of the gameplay in Teapot Wars is defined in Lua. You can find
these Lua scripts in Dev/Assets/Scripts. If you are using Decoda, there
s even a Decoda
project file there for you to use. Before digging too deeply into the gameplay imple-
mentation, I
'
d like to talk a bit about the design.
The level is a simple grid where you and one of enemies face off in a battle to the
death. Multiple teapots enter, but only one will survive. If any teapot falls off the
grid, that teapot dies. Each teapot can take three hits before being destroyed,
although everyone is periodically healed.
AI teapots in the world are controlled by the decision tree you saw in Chapter 18,
'
Teapots will patrol two points on the grid until one
of their foes approaches; then they attack! If the AI teapot drops to one hit point, it
will run until it gets healed.
Now that you have a little context, load up the game and play around with it for a
bit. Come back when you ' re ready, and I ' ll show you how the level is loaded.
An Introduction to Game AI.
Loading the Level
When the game starts up, a level XML file is loaded to determine which actors to
create and where to create them. It also determines which script files to load. For
 
 
 
 
Search WWH ::




Custom Search