Game Development Reference
In-Depth Information
Creating the Sweet Beastie Object
1.
Go to the
Resources
menu and select
Define Constants
. Add four new constants called
ESTATE_WAIT
,
ESTATE_MOVE
,
ESTATE_DECIDE
, and
ESTATE_ATTACK
and assign them the
values
0
to
3
, consecutively. If you don't have the Pro version of Game Maker, then you
will need to define these as variables at the start of the
Create
event instead (in step
three).
2.
Create a new object called
obj_beastie
(
Hazards
group), give it
spr_beastie_walk_right
, and set its parent to
obj_enemy
.
3.
Add a
Create
event and include a
Set Variable
action (
control
tab) that sets the
Variable
state
to
ESTATE_MOVE
. This will be the starting state for the Beastie.
4.
Include a second
Set Variable
action that sets the
Variable
facing
to
FACE_LEFT
.
5.
Include a third
Set Variable
action that sets the
Variable
image_speed
to
0.2
. This slows
down the animation speed of the sprite without needing a
Change Sprite
action.
6.
Add a
Destroy
event and include a
Set Variable
action that sets the
Variable
global.die_sprite_index
to
spr_beastie_die
.
7.
Include a
Call Parent Event
action that will thereby handle the rest of the process of
creating dying enemy instances and the splat.
8.
Add a
Draw
event. This will handle the drawing of the correct left- and right-facing
sprites in different states in a similar way to the Zool object.
9.
Include a
Test Variable
action that checks if the
Variable
facing
is
equal to
FACE_LEFT
.
10.
Follow this with a
Start Block
action.
11.
Include a
Test Variable
action that checks if the
Variable
state
is
equal to
ESTATE_WAIT
.
12.
Follow this with a
Draw Sprite
action (
draw
tab) that draws
spr_beastie_stand_left
at
a
Relative
position of
X
=
0
,
Y
=
0
.
13.
Include a
Test Variable
action (
control
tab) that checks if the
Variable
state
is
equal to
ESTATE_MOVE
.
14.
Follow this with a
Draw Sprite
action (
draw
tab) that draws
spr_beastie_walk_left
at
a
Relative
position of
X
=
0
,
Y
=
0
.
15.
Include another
Test Variable
action (
control
tab) that checks if the
Variable
state
is
equal to
ESTATE_ATTACK
.
16.
Follow this with a
Draw Sprite
action that draws
spr_beastie_attack_left
at a
Relative
position of
X
=
0
,
Y
=
0
.
17.
Follow this with an
End Block
action. Note that there is no case for
ESTATE_DECIDE
, as
this state will automatically switch to
ESTATE_MOVE
or
ESTATE_ATTACK
before it is drawn.
18.
Repeat steps 9-17 and create the right-facing equivalents. You should be able to handle
this on your own by now. If you want to
Copy
and
Paste,
then try adding a
Comment
action (
control
tab) to the end of the list of actions first and pasting over that.
Search WWH ::
Custom Search