Game Development Reference
In-Depth Information
Spitting Mad
Life is about to get a lot more dangerous for our ninja friend, and there is a smell of aniseed in the
air as his enemies start to spit missiles in his direction. These projectiles will bounce around the
landscape for a while too, making them an even more lethal hazard.
Creating the Sweet Beastie Missiles
1. Create a new object called obj_beastie_missile ( Hazards group), give it the
spr_beastie_missiles sprite, and set its Parent to obj_hazard .
2. Add a Create event and include a Play Sound action ( main1 tab) to play
snd_enemy_missile .
3. Include a Change Sprite action for spr_beastie_missiles that sets Subimage to
random(image_number) and Speed to 0 . This randomly selects one of the multicolored
missile images and stops the sprite from animating.
4. Include a Set Gravity action ( move tab) that sets the Gravity to 1 in direction 270 .
5. Include a Set Alarm action ( main2 tab) that sets Alarm 0 to 90 steps. This will be the
lifespan of the missile (three seconds).
6. Add an Alarm, Alarm 0 event and include a Destroy Instance action ( main1 tab) to
destroy Self .
7. Add a Step, Step event and include a Test Variable action ( control tab) that checks if
the Variable speed is larger than 8 . This is to make sure that the missile doesn't
accelerate too fast under gravity and break the collision (discrete time sampling again).
8. Include a Set Variable action that sets the Variable speed to 8 .
9. Add a Collision event with obj_platform and include a Set Variable action that sets x to
xprevious . We're handling the collision with the platforms in the usual way, but we'll
make the missiles bounce as well.
10. Include a second Set Variable action that sets y to yprevious .
11. Include an Execute Script action that sets Script to move_to_contact_with , Argument0
to direction , Argument1 to -1 , and Argument2 to
ob
j_solid .
12. Include a Reverse Vertical action ( move tab).
13. Repeat steps 9 - 12 for collisions with obj_wall , but use the Reverse Horizontal action
instead. Alternatively, you could duplicate and edit the platform collision event.
14. Add a Collision event with obj_zool and include a Destroy Instance action ( main1 tab)
for Self . The fact that the missile has obj_hazard as a parent already means that Zool
will be hurt by missiles in the same way as the spikes, but unlike the spikes, we want
the missiles to disappear on contact.
15. Now reopen obj_beastie and select the Step event.
16. Find the Test Variable action that uses the point_distance function. Edit the Set
Variable action that comes directly after it to set state to ESTATE_ATTACK instead of
ESTATE_WAIT .
 
Search WWH ::




Custom Search