Platformer Enhancements - Wall Jumping

6

Index

Stats

22,114 visits, 73,381 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 28 Jan, 2013. Last updated 19 Feb, 2019

Enable Wall Jump as a Power Up

27. Now that we have a great wall jump mechanic, lets take it a step further. For some games it maybe that you don't want the player to wall jump unless they pickup a power up of some type. Maybe a magnetic boots attachment, or a stick to wall power up. Lets implement something like this. First just like we did for our walls, we are going to create a new sprite to represent our power up. It will simply be a red square. Once the player get's it, we will turn on the ability to wall jump. Create a new sprite, draw it as a square, call it powerUp and make it red:

28. Lets now add a variable called hasPowerUp that will track if the player has the power up or not. This is pretty easy. Create a global variable call hasPowerUp on your event sheet. Set it's initial value to 0 (0 represents false).

29. We need to add an event that allows the player to get the power up when they touch it. We will add an event to the player that detects if they are touching the power up. If they touch it, we set the hasPowerUp variable to 1, and then destroy the power up so it disappears. We will use the following event:

Player On Collision with powerUP, System Set hasPowerUp to 1, Destroy powerUp

Your event sheet will look like the following:

30. Now lets update our wall jump events to check if the player has the power up. Since all conditions have to be true for an event to fire, if the player does not have the power up, they will not be able to wall jump. Add the following condition:

System hasPowerUp = 1

Your event sheet should now look like the following:

31. Now we will create an event that checks the value of hasPowerUp, and if it is 1, it will wait 5 seconds and then set it back to 0. Basically this allows the Wall Jump Power Up to last for 5 seconds. And then turns it off for us. There may be more efficient ways of doing this, but this is simply one of the quickest ways to implement the behavior. Create the following condition:

System hasPowerUp = 1 System Wait 5 Seconds, System set hasPowerUp to 0

Your event sheet should look like this:

  • 0 Comments

Want to leave a comment? Login or Register an account!