WolfMerrik
New member
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:
You will need to add this variable to SystemVariables.asm
First, we want to define what happens when we release the jump button.
This script is done when the "Jump" Botton is released:
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 :
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!
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:
; 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:
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:
; 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:
; 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!