Game Development Reference
In-Depth Information
Figure 4-7. Zool's origin is at X=24, Y=24 and his bounding box extends 18 pixels above and below this.
That means that the pixel on the bottom row of his bounding box is 18 pixels below his y position
Give it a try. It's not such a pretty-looking sequence of actions any more, but it works and
that's what counts! Next, we will begin to open up the test level a bit more by adding the climbing
movement mechanic.
Driven up the Walls
One of Zool's unique abilities as a platform game character was to be able to cling to vertical
walls. We're going to implement this behavior using the (as yet untouched) obj_zool_wall state
object. We're not going to make Zool's climbing speed increase and decrease gradually like it
does on the ground, but just set his speed to a constant value when the player presses a key.
When Zool is moving, he will be in the climbing state, and when he isn't, he'll be in the clinging
state; there is no separate sprite for this and clinging will just use the first frame of the climbing
sprite. As in previous state objects, we will use the Begin Step event to set his default state
(clinging) and use the End Step to update his state when there is no longer a wall to cling to:
The Zool Wall State Object
Begin by reopening obj_zool_wall and setting the depth to -1001 . Unlike the other
state objects, we want Zool to appear in front of both tile layers when he is climbing up
a wall.
1.
2.
Add a Create event and include a Set Variable action ( control tab) with Variable set to
state and Value set to ZSTATE_CLIMB .
Include a Set Gravity action ( move tab) that sets Direction to 270 and Gravity to 0 .
Gravity is not helpful while Zool is climbing.
3.
 
Search WWH ::




Custom Search