Game Development Reference
In-Depth Information
3.
Now use spr_zool_slip_left to create left-facing equivalents of these two new actions
within the block for FACE_LEFT . This is now a very long event containing 34 actions, but
all following the same simple structure that you should be familiar with by now.
Reopen obj_zool_land and select the End Step event. Include a new Check Object
action ( control tab) to check for the Object obj_slope , at a Relative position of X = 0 ,
Y = 1 .
4.
5.
Immediately follow this with a Change Instance action ( main1 tab) that will change
into obj_zool_ice and Perform Events ( Destroy and Create ) as it does so.
6.
Reopen obj_zool_air and add a Collision event with obj_slope . Include a Set Variable
action ( control tab) to set the Variable y Relative to -speed*2 . Just as for the ramp
object, this moves Zool upward to compensate for the overlap with the slope object.
We multiply speed by 2 this time because Zool is not just moving horizontally and so
can be even further below the surface of the slope.
Include a Move to Contact action ( move tab) that sets Direction to 270 , Maximum to
-1 , and Against to all objects . This will bring Zool back down in contact with the slope.
7.
Include a Change Instance action ( main1 tab) that will change into obj_zool_ice and
Perform Events ( Destroy and Create ) as it does so.
8.
Implementing Behaviors for the New Ice State Object
1.
Open obj_zool_ice and add a Create event. Include a Set Friction action ( move tab)
that sets Friction to 0.25 (we want our slopes to be quite slippery). Unlike the other
state objects we're not going to set the state variable in the Create event as this will
immediately affect the sprite that is drawn. We need to do some tests on the steepness
of the slope before we can decide which subimage of the slipping sprite to use, so it's
best not to switch to the slipping sprite until then. We'll do all this in a Begin Step
event instead.
2.
Add a Step, Begin Step event and include a Set Variable action ( control tab) that sets
the Variable state to the Value ZSTATE_SLIP .
3.
Include a Set Gravity action ( move tab) with a Direction of -1 and a Gravity of 1 . This
is the default gravity setting for when the slope is horizontal and Zool should keep
moving forward at a tiny downward angle (as that seems the most logical default).
Include a Set Variable action ( control tab) that sets the Variable image_index to the
Value 2 . This makes sure the horizontal sprite sub-image is shown by default too.
4.
Include a Check Object action that checks for the Object obj_slope_u1 at the Relative
position of X= 0 , Y = 1 .
5.
6.
Immediately follow this with a Start Block action.
7.
Include a Set Gravity action ( move tab) with a Direction of 202.5 and a Gravity of 1 .
We have to add 180 to 22.5 degrees to get an angle slopping downwards and to the left.
Include a Set Variable action ( control tab) that sets Variable image_index to Value 0 .
8.
9.
Include an End Block action. This set of actions now sets the appropriate gravity
setting and sub-image for obj_slope_u1 .
 
Search WWH ::




Custom Search