|
Post by johnlobo73 on Dec 22, 2021 13:37:43 GMT
Hi all,
Is it possible in mpagd to implment double jump?? This is excuting a second jump while you are on the air from a first jump.
Thanks in advance.
John.
|
|
mrtomftw
Abandoned Uranium Working

Posts: 15
|
Post by mrtomftw on May 28, 2022 16:54:19 GMT
A late answer, but I've solved this one myself. There is a small issue, which I'll get to at the end but otherwise it works. Also this requires use of a variable to record if the player has double jumped or not already.
In the Player event:
IF CANGODOWN ;your code goes here ELSE LET SETTINGA = 0 ;Player is on the ground, therefore double jump resets IF KEY FIRE JUMP 8 ;A normal jump, replace the number with whatever you want it to be, obviously ENDIF ENDIF
IF AIRBORNE > 10 ;You can't use "AIRBORNE <> 0" otherwise it'll just check for KEY FIRE on the very next frame and trigger the double jump before you can release fire. So you wait 10 frames. IF SETTINGA = 0 ;Checking to make sure you haven't already double jumped IF KEY FIRE LET SETTINGA = 1 ;We're double jumping! STOPFALL ;You've got to STOPFALLing, otherwise it won't let you jump JUMP 8 ;Jump! ENDIF ENDIF ENDIF -----
The caveat: You might have already realised this through the code/comments. As long as you're holding fire, the game will register IF KEY FIRE as TRUE on every frame the button is held for. I can't find any way to force MPAGD to stop registering it after a jump, and make a new press necessary. SO if you don't have a delay (which is the IF AIRORNE > 10 line) it'll make you double jump on the very next frame, which makes it seem like just one jump. If the player holds down fire, after the delay it'll trigger the double jump which isn't perfect, but at least it works. Play around with that delay, see what feels good to you but bear in mind if the delay is too long, then it may reduce the usefulness of the double jump as players may not be able to double jump as quickly as they'd like.
I've said double jump a lot. I hope this makes sense. If anyone can suggest any improvements I would be grateful.
|
|
|
Post by Minilop on May 29, 2022 14:18:33 GMT
Hey Mr Tom, That's a good solution!, here's a slightly different way which includes key debouncing, so the double jump is not triggered automatically and it forces you to release the jump key after the initial jump before pressing it again for the double jump, in this example I've used J as my jump variable but could easily be switched to SETTINGA as per your example (the game I was working on that includes this already uses SETTINGA for something else)
IF KEY FIRE IF J = 0 ; J is our jump status JUMP 6 LET J = 1 ; player has Jumped set status to 1 ENDIF
IF J = 2 ; double jump is possible STOPFALL JUMP 6 LET J = 3 ; double jump has occured ENDIF ELSE ; player is not pressing jump IF J = 1 ; if jump flag is active and we've released the jump key LET J = 2 ; set jump flag to double jump possible (2) ENDIF IF J = 4 ; if player had jumped then landed and now released jump LET J = 0 ; reset the jump status ENDIF ENDIF
IF AIRBORNE = 0 ; PLAYER HAS LANDED IF J >= 1 ; if player had jumped or double jumped LET J = 4 ; set status to 4 and await jump key being released ENDIF ENDIF
Hope this helps!, I've written this up as a tutorial and added it to the library here with a video that show it in action: www.minilopretro.com/post/double-jump-with-key-debouncing
|
|