RAD Jump (a better multijump framework)

User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

RAD Jump (a better multijump framework)

Post by WolfMerrik » Wed Sep 05, 2018 4:58 pm

RAD Jump!

So, I made a VASTLY improved jump script, which allows for a configurable amount of jumps/extra jumps.
This could easily be modified, improved, to make items that give double jumps as a powerup/etc.
It also fixes the "Bouncing" that happens when holding A, as it uses presses vs holding.

I had made some changes to my platform physics scrips, so hopefully, this works well with the default platformer module!

Please let me know what you think in a reply below.

Here are the two scripts:
DoubleJump_Rad.asm v1.0
JumpRelease_Rad.asm v1.0

You will need to add these constants to Constants.asm
You can, of course, change the values, just remember, it uses "negative" numbers, which are #$00 as 0, #$FF as -1, etc
This saves on math operations over the last script.

If you did want to add a variable jump_height/speed item, you could still do this by adding a few lines of code.

The constants are:

Code: Select all

; Rad Jump Constants:
; We use NEG Numbers, and save on math operations
JUMP_RELEASE_HEIGHT = #$FD	; When we release the jump
JUMP_HEIGHT = #$FA		; The jump Height
JUMP_HEIGHT_DOUBLE = #$FC	; The double jump Height
JUMP_EXTRA_LIMIT = #$02		; Max number of "Double" jumps!
You will need to add this variable to SystemVariables.asm

Code: Select all

jumpStatus .dsb 1	; Basically a counter for the multi jumps
First, we want to define what happens when we release the jump button.
This script is done when the "Jump" Botton is released:

Code: Select all

; JumpRelease_Rad.asm v1.0 by WolfMerrik
; Use on "Release A" Input (Or your jump button of choice)
; This works very similarly to the old method, but with better comments & optimizations

LDA #JUMP_RELEASE_HEIGHT	; The constant we will be comparing against. Use a predefined negative
LDX player1_object		; Load the player object to the X register for compare/setting
CMP Object_v_speed_hi,x		; Compare our v-speed with the jump release height (Speed)
BMI skipJumpRelease		; If the speed is below the jumping (reverse falling speed)
LDA #JUMP_RELEASE_HEIGHT	; Load the new release speed/height
STA Object_v_speed_hi,x		; Set it!
skipJumpRelease		; Did not need it
RTS
This file is available here: JumpRelease_Rad.asm v1.0


The next script handles all the jumps, detects the ground flags, adds to the counter, etc
This will be done when the "Jump" button is pressed :

Code: Select all

; DoubleJump_Rad.asm v1.0 by WolfMerrik
; Use on "Press A" Input (Or your jump button of choice)
;    Using this as a "press" avoids that weird bouncing we got with the old script
;     Much more than a double jump, but a multi-jump
;     You can define how many "DoubleJumps" you can do in constants
;     You could even add an item that increases this with a variable easily
;     This would be done to canDoubleJump, and you would ADC, or SBC the jump items value.
;     The same could be done of course with jump height (high jump boots anyone?)

LDA jumpStatus
CMP #$00
BEQ firstJump
JMP doubleJumpCheck

firstJump:
    LDX player1_object
    LDA Object_status,x
    AND #%00000100	; Are we on the ground?
    BNE canJump		; We are NOT on the ground
    RTS
    
canJump:    
    LDA #JUMP_HEIGHT
    STA Object_v_speed_hi,x	; Set the jump height!
    LDA Object_status,x
    AND #%11111011
    STA Object_status,x
    ChangeObjectState #$02, #$02    ; Jump animation state
    LDA #$01
    STA jumpStatus		; Set the Jump status to "1"  
    JMP doneJumping		; Jump to done jumping. haha

doubleJumpCheck:
    LDA Object_status,x	; Are we on the ground?
    AND #%00000100
    BEQ canDoubleJump	; If we are, let's jump normally!
    LDA #$00
    STA jumpStatus
    JMP firstJump	; We were on the ground... so let's try to jump again normally!

canDoubleJump:
    LDA #JUMP_EXTRA_LIMIT
    SEC 
    SBC jumpStatus
    BMI doneJumping
    LDX player1_object
    LDA #JUMP_HEIGHT_DOUBLE
    STA Object_v_speed_hi,x
    LDA Object_status,x			; For some reason... this ust be set again
    AND #%11111011			; It sometimes fails without
    STA Object_status,x			; Not sure why!
    ;ChangeObjectState #$03, #$03	; Double Jump State Would go here
    LDA jumpStatus
    ADC #$01
    CLC
    STA jumpStatus		; Add one to the jump Status! We could expand, and make the third jump less, etc

doneJumping:
    RTS
This file is available here: DoubleJump_Rad.asm v1.0

Hopefully, you like it, and I would love to have your feedback, and hear about what you do with it!
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
SuperNatetendo
Posts: 79
Joined: Wed Aug 08, 2018 4:51 pm

Re: RAD Jump (a better multijump framework)

Post by SuperNatetendo » Wed Sep 05, 2018 6:10 pm

...

you're the best dude. Dear lord this is great.
User avatar
dale_coop
Posts: 4376
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: RAD Jump (a better multijump framework)

Post by dale_coop » Wed Sep 05, 2018 6:20 pm

Great, WolfMerrik! Will try that tonight or tomorrow <3
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
digit2600
Posts: 178
Joined: Mon Apr 16, 2018 9:50 pm

Re: RAD Jump (a better multijump framework)

Post by digit2600 » Wed Sep 05, 2018 9:24 pm

fuckin' gnarly! i can't wait to try this out !
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: RAD Jump (a better multijump framework)

Post by WolfMerrik » Thu Sep 06, 2018 1:27 am

I'm glad to see people like it! It still needs some work, and it meant as a very basic script to be expanded on (no sfx, etc)
But I definitely like how it came out well, and beats the hell out of my old jump script haha =P
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
Imagaryboy
Posts: 18
Joined: Mon Aug 20, 2018 9:05 am
Location: Cologne

Re: RAD Jump (a better multijump framework)

Post by Imagaryboy » Thu Sep 06, 2018 8:43 am

This is really great, thank you for sharing this!!!

Were you able to solve the problem with the collision detection that caused a 2-5 frame window where jumping is not possible?

Because I still have this problem, even with this new script :/
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: RAD Jump (a better multijump framework)

Post by WolfMerrik » Thu Sep 06, 2018 3:11 pm

Imagaryboy wrote:
Thu Sep 06, 2018 8:43 am
Were you able to solve the problem with the collision detection that caused a 2-5 frame window where jumping is not possible?
Sadly, not yet. Even as I have been digging into the physics a lot lately, I have still not find a "why" that it is happening... IF I can find this, I can hopefully create a "how" lol
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
digitalbooty
Posts: 36
Joined: Fri Oct 19, 2018 7:42 pm

Re: RAD Jump (a better multijump framework)

Post by digitalbooty » Mon Oct 22, 2018 9:31 am

Thanks for making this! I set these as my new press and release script actions for button A. It will let me jump twice and then it won't let me jump anymore. Not even on the ground. Is there a setting in the script I need to set?
SubCog
Posts: 12
Joined: Wed Dec 26, 2018 4:32 pm

Re: RAD Jump (a better multijump framework)

Post by SubCog » Thu Dec 27, 2018 9:36 pm

I'm having the same issue. The double jump works fine the first time, but then once I hit the ground it never lets me jump again. Any ideas what I'm doing wrong?
User avatar
dale_coop
Posts: 4376
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: RAD Jump (a better multijump framework)

Post by dale_coop » Fri Dec 28, 2018 7:57 am

Did you set all the scripts according to the original post? (Constants.asm, SystemVariables.asm, JumpRelease_Rad.asm assigned to the "release" A button and DoubleJump_Rad.asm to the "press" A button)
Tried again today with a fresh 4.0.11 platformer demo and it works well.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
Post Reply