Game Development Reference
In-Depth Information
Numb Skulls
Pirates are not known for their intelligence, and ours certainly aren't going to break the
tradition. Nonetheless, we don't want them to seem completely oblivious to Flynn and Archie,
so we will give them the ability to spot and pursue both the player and the sidekick. To make this
feel more realistic, we'll do it using a basic line-of-sight test, which will make it possible to
sneak up on pirates through clever use of the landscape.
We've already created a hierarchy of skeleton objects, including a parent object
obj_skeleton , which is itself a child of obj_enemy . We've chosen to use two separate state objects
to implement the pirate's different behaviors: obj_skeleton_land and obj_skeleton_air . These
follow a similar pattern to the Flynn object, inheriting their Draw event from obj_skeleton to
draw the appropriate sprite in different states. The obj_skeleton_air object has already been
implemented for you, as it does little more than fall under gravity and recover or die depending
on how far it has fallen. This is all behavior you have seen already, but obj_skeleton_land will
have some more interesting behaviors that are worth implementing for yourself.
Before we begin, also take a look at the new is_passible_for_enemy Script resource. It's a
simple script that basically just tests for all the different kinds of things that can get in the way
of a skeleton's path (including a lack of ground to stand on!) and returns false if any of these
situations exist—otherwise, it returns true . It is easier to have a single way of checking for all
these obstructions at the same time because we will need to use it more than once in the code.
Footsteps on Deck
Patrolling up and down is pretty much what you expect as a default behavior for baddies, so this
is what we'll implement first. Initially, you should be able to spot some similarities with the
Beastie enemy object in Zool , but it will soon take on a new direction. We're only intending
skeletons to patrol flat areas of the level, and not ramps, but it would be reasonably simple for
you to support them too by copying code from obj_flynn_land .
Implementing the Moving Behavior for the Skeleton Object
1.
Open the Create event of obj_skeleton_land and change the line that sets the state to
ESTATE_WAIT and set it to ESTATE_MOVE instead.
Add a Step, Step event to obj_skeleton_land and include an Execute Code action with
the following code:
2.
 
Search WWH ::




Custom Search