Author Topic: How to make jump refreshers accumulate the amount of remaining jumps?  (Read 1360 times)

l3agu32

  • Wannabe
  • Posts: 22
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
  • Playstyle: Keyboard
I think I only saw this in "I wanna jump the rainbow". In most games if you collect sequential jump refreshers, you have only one remaining jump, but in "I wanna jump the rainbow", each jump refresher adds one more remaining jump. How to do this coding in game maker studio with yoyo engine? Thank you!

klazen108

  • Administrator
  • The Kid
  • Posts: 286
  • your a kid now your a squid now
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
    • Delicious-Fruit
  • Playstyle: Keyboard
Normally, when you press the jump key while in midair, the engine will check if djump==1, then set djump=0. And when you touch a jump refresher or land on a block/platform, it will set djump=1. Looking at this, we see djump is treated as a true/false condition, rather than as a counter. Luckily it's fairly straightforward to change this from a boolean true/false to a counter: every time you touch a jump refresher, ADD one to djump. When you jump in midair, check if djump is GREATER than zero, and if so, jump and SUBTRACT one. If you land on the floor, do you want to reset your counter so you only have one jump again? if so, set djump=1. Otherwise, if you want to keep your counter, only set it back to one if it's zero.

Depending on the engine you are using, your experience may differ slightly, but the concept is the same. I wrote an example for adding triplejump to the yoyoyo studio engine here - you won't want to copy that exactly since it's not the effect you're looking for, but it should help you find all the places where djump is referenced (it also might be outdated since the engine has changed since I wrote it). If you're not using the yoyoyo engine, just go to Scripts > Search in Scripts up in the menu bar, and search for djump and it will show you everywhere in your engine that it is used.

YoSniper

  • Awexome
  • Global Moderator
  • Spike Dodger
  • Posts: 142
  • People regard me as a programming overlord.
  • OS:
  • Windows 10 Windows 10
  • Browser:
  • Chrome 51.0.2704.103 Chrome 51.0.2704.103
    • View Profile
    • My YouTube
  • Playstyle: Keyboard
The variable names may have changed since I last looked, but it could go something like this:

In the playerJump script, make sure that the double-jump handling is similar to this:
Code: [Select]
if not place_free(x, y+1) {
    vspeed = -1 * jump_speed;
} else if djump > 0 {
    vspeed = -1 * djump_speed; //Guessing at the variable name here, but it should be clear.
    djump -= 1; //This subtracts one mid-air jump from the available jumps.
}

In the Jump Refresher code, when colliding with the player, all you would need in this case is:
Code: [Select]
other.djump += 1; //Assuming "other" refers to the player instance colliding with the refresher.
I don't traverse the forums as much anymore. Follow me on Twitter if you want to keep tabs on me!

Twitter: @YoSniperGames
Twitch: yosniper

Streams happen whenever I feel like it.