Jumps and collisions
Jumps and collisions
Jumping over the obstacles
The snowboarder can jump over the trees and rocks.
- Upon pressing "Space bar"
(snowboarder) : Change animation sequence to Jumping
Collision with the trees
We must detect the collisions between the snowboarder and the trees:
- We first test if the two objects are overlapping
- Then if the player lays in front of the tree (by comparing the vertical coordinates)
- Finally that the player is not jumping (with the Negate menu option).
When the player hits the obstacles all these conditions are true. One life is then subtracted from the number of lives and the frame is restarted.
- (snowboarder) is overlapping (pine)
+ Y position of (snowboarder) <= Y( " (pine)" )
+ X (snowboarder) animation Jumping is playing
(Player 1) : Subtract 1 from Number of Lives
: Restart current frame
Collision with the rocks
We use the same logic to program the collision detection with the rocks. Notice that the events are identical.
(snowboarder) is overlapping (rock)
+ Y position of (snowboarder) <= Y( " (rock)" )
+ X (snowboarder) animation Jumping is playing
(Player 1) : Subtract 1 from Number of Lives
: Restart current frame
Spread the word!
You can share this document using the following buttons.