I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: Junior Nintendista on October 05, 2015, 05:18:13 PM

Title: How to make a triple jump?
Post by: Junior Nintendista on October 05, 2015, 05:18:13 PM
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.
Title: Re: How to make a triple jump?
Post by: klazen108 on October 05, 2015, 11:47:12 PM
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 (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.