Graphics Reference
In-Depth Information
Figure 15-31 The final game setup
The object of the game is to collect the cones without hitting a wizard. When you collect all eight cones,
you'll see a congratulatory message, and the game will end. If you hit a wizard, the game will end and the mes-
sage won't be so congratulatory. The green balls make you bounce up and down, enabling you to get a view
of the layout of the maze and the locations of the cones, and also protect you from the wizards. Of course, the
effect of the green balls is temporary.
To set up these game-play features, you need to add logic to the cones and balls and add a bit more logic
to the Empty object. The temporary protection you get from picking up the green balls will require the use of
states in the character logic.
Using Cone, Ball, and Empty Logic
Thelogicassociated withtheConeobject issimple, asyoucanseein Figure15-32 . ANearsensorisused,with
a distance of 0.25 to determine when the character is close enough to touch the cone. The character is recog-
nized by the char property. When the conditions on the sensor are met, two actuators are activated. The first is
an Edit Object actuator set to End Object, which removes the Cone object from the scene. The second actuator
is a Message actuator, which broadcasts a message with cone_touch as its subject. This message will be re-
ceived by the Empty object and will result in incrementing the point counter on the Empty object, as shown in
Figure 15-33 .
The logic on the ball is almost the same as the logic on the cone, as you can see in Figure 15-34 . The only
difference is the subject of the message that gets sent. In this case, the subject is ball_touch . This will be
received by the armature and will initiate the special protected state as described in the next section.
 
 
 
 
Search WWH ::




Custom Search