Name: Double Jump
Description: The player is able to jump in the middle of another jump but only once. Pressing the jump button a third time with have no effect.
Need for Pattern: Having a double jump is a way of allowing the player to access areas not possible with a single jump. Double Jumps also require good timing from the player too so this can increase challenge depending on the design of your game.
Related Game Patterns: Jumping on Enemies [related]
Coding Concepts involved: Data, Change Listener
Links to other Computing Patterns: Systems Dynamics,
We need to create a variable called canDoubleJump. Now add a block at the start of our game and set it to true to start with.
Then you need to use blue logic blocks to check to only jump if
Once the player has used up their double jump ability, you set the canDoubleJump variable to false. This stops the player from being able to jump more than twice.
Then we must create to code to reset the canDoubleJump variable when you touch the ground again. To do this create a on game update loop and put a logic block in there which will turn canDoubleJump true when you are touching the ground again.
Test your game to check that your changes have the desired behaviour and no side effects. To check that you are making the most of this pattern you can ask yourself the following questions:
This Game Pattern is one of many allowing you to make improvements to your platform game and to learn coding and wider computing concepts. Find more on the Game Pattern page.