Fangames > Programming Questions

How to make jump refreshers accumulate the amount of remaining jumps?

(1/1)

l3agu32:
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:
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:
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: ---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.
}
--- End code ---

In the Jump Refresher code, when colliding with the player, all you would need in this case is:

--- Code: ---other.djump += 1; //Assuming "other" refers to the player instance colliding with the refresher.
--- End code ---

Navigation

[0] Message Index

Go to full version