Game Development Reference
In-Depth Information
Adding Shooting Behavior to Zool
1. Create a new object called obj_zool_missile ( Zool group) and give it the
spr_zool_missile sprite.
2. Add a Create event and include a Play Sound action ( main1 tab) for snd_shoot .
3. Add a Collision event with obj_enemy and include a Destroy Instance action for Other .
4. Include a second Destroy Instance action for Self . We want missiles to destroy
enemies, but the missile should be destroyed as part of the collision too.
5. Add a Collision event with obj_solid and include a Destroy Instance action for Self .
6. Add an Other, Outside Room event and include a Destroy Instance action for Self . We
don't want missiles flying along forever when they will never come back into play.
7. Reopen obj_zool and add a Key Press, Ctrl event. Include a Create Moving action
( main1 tab) that creates an instance of obj_zool_missile at a Relative position of
X = facing*8 , Y = 0 with a Speed of (facing*8)+hspeed and a direction of 0 . We use this X
position so that the missile appears just in front of Zool (rather than the center of
Zool's body). Similarly, we use this Speed because we want the missile to move in the
direction Zool is facing, but we need to add on Zool's moving speed, otherwise he
could shoot bullets that are actually travelling slower than he is. We can always use a
Direction of 0 because the speed of the bullet will be negative if it is moving left.
8. Reopen obj_zool_wall and add a Key Press, Ctrl event that includes an Exit Event
action ( control tab). As we have put the previous event in the parent object, it would
be possible to shoot in all the different Zool states. However it doesn't really make
sense for Zool to be able to shoot while climbing so this simply overrides the Key Press
event with one that does nothing when Zool is in the wall state.
At this point, you should have a fighting-fit ninja to take on the enemies we created earlier. If
you've not done so already, then now might be a good time to populate the level with a range of
enemies and test out your ninja skills. As usual, you can save time by loading our version from the
file zool12.gmk in the Chapter06/Games directory on the CD.
Uplifting Platforms
Up until now, we've avoided the concept of moving platforms as they are potentially quite tricky
to implement. After all, they have to move the character as well as themselves and the character
still needs to be able walk and jump across them as if his movement was relative to theirs. The
easiest way to implement moving platforms is to have a platform of a fixed size, so that you are
just working with a single platform object, but this isn't the way they worked in Zool. They were
made up of individual segments, so that platforms could be constructed of any length. However,
as you'll discover, this makes things trickier….
 
Search WWH ::




Custom Search