Game Development Reference
In-Depth Information
Up and Down
The good news is that making separate platform segments move vertically is not so hard. As the
platforms themselves are horizontal, each segment can move vertically without having to worry
about the segments on either side of them getting in the way. We're going to call our moving
platforms “lifts” and make them children of obj_ledge , as we want to be able to jump up through
the lifts and land on top of them. We're going to create separate objects for moving in different
directions, as this makes the horizontal platforms possible later. We'll also create some limiter
object for the lifts, like we did for the enemy objects.
Creating Vertical Lifts
1. Begin by defining a new constant called LIFT_SPEED that is set to 2 . It's a good idea to
declare constants in this way if you are going to use them in several different objects,
as it saves you from having to find and edit all the different actions if you want to
change the value. However, if you are using the Lite version, then just replace this
constant with a “hard-coded” value of 2 when you see it in this list of steps.
2. Create a new object called obj_lift (create all of these lift-related objects in the
Platforms , Lifts group) and set its Parent to obj_ledge .
3. Create a new object called obj_lift_vlimit , give it the spr_lift_vlimit sprite, and
disable the Visible option.
4. Create two new objects called obj_lift_up and obj_lift_down . Give them the
appropriate lift sprites, set their Depth to -1001 , and their Parent to obj_lift .
5. Add a Create event to obj_lift_up and include a Speed Vertical action ( move tab) that
sets Vert. Speed to 0 . The platforms will stand still for a while as they change direction.
6. Include a Set Alarm action ( main2 tab) that sets Alarm 0 to 90 Steps (3 seconds). This
alarm will start the platform moving again.
7. Add an Alarm, Alarm 0 event and include a Speed Vertical action ( move tab) that sets
Vert. Speed to -LIFT_SPEED .
8. Add a Collision event with obj_solid and include a Set Variable action ( control tab)
that sets y to yprevious . We don't need to bother with x, as this platform doesn't move
horizontally.
9. Include a Change Instance action ( main1 tab) that changes into obj_lift_down with
Perform events set to yes .
10. Right-click on the Collision event with obj_solid and Duplicate Event to create an
identical Collision event with obj_lift_vlimit . The same actions are required when
colliding with the limiter, but limiters are not solid (otherwise Zool would start
colliding with them too).
11. Repeat steps 5-10 for obj_lift_down , setting the Vert. Speed in the Alarm 0 event to
LIFT_SPEED and using obj_lift_up for the Change Instance action instead.
You can now add instances of either obj_lift_up or obj_lift_down to the test level in order to
see their effects. Obviously, you will eventually want to avoid situations that would squash the
player against the underside of a platform, so that's what obj_lift_vlimit is for. However, this is
arbitrary at the moment, as Zool can't yet stand properly on the platforms. But before we do that
we will tackle the trickier horizontal platform segments.
 
Search WWH ::




Custom Search