Fangames > Programming Questions

How to make a triple jump?

(1/1)

Junior Nintendista:
I saw this mechanics in I Wanna Jump The Rainbow and found it interesting.Anyone knows how to do this kind of leap, I would be grateful.

klazen108:
Most (all?) engines use a value called 'djump' to determine if your player can jump again. However, they just check for "true" or "false" - if true, you can, if false, you can't. Adding triple jump is fairly straightforward; instead of using it as a true/false check, use it as a counter - check if djump is greater than 0 to double jump, and remove one for each time you jump.

Take a look a this example: https://klazen.com/gm/8g (pay attention to the green comments - they explain what's changing between the two sections). On player collision with block, we set djump to 2. then, in the playerJump script, check if djump is greater than 0, and if so, subtract 1 and jump.

I tested this in the YoYoYo Engine for GMStudio, but the concept applies to all engines I can think of. Just edit those mentions of djump and you should be good to go! You can ignore the three sections at the bottom of the script snippet if you're not using the YoYoYo Engine, they're only there for completeness and shouldn't be necessary if you're using Yuuutu or a similar engine. Do check the player's create event though - you may need to set djump=2 there as well.

Navigation

[0] Message Index

Go to full version