WolfMerrik
New member
Now, this is VERY simple and basically reappropriates the original (plus my first mod) code in the platformer tutorial to make a double jump.
But it does achieve a "Double Jump" mechanic
FIRST, we need to make two vars:
These will be in SystemVariables.asm
Then we look at the new Jump Script...
I named this playerDoubleJump.asm, and I assigned it to the hold "A" input
Next, we look at the release script, which is also VERY similar to the original,
I named mine varPlayerDoubleJumpRelease.asm, and you guessed it! It is called on "A"'s release
Now, we set a new script, this one I called: playerDoubleJumpPress.asm
I use it when the "A" button is pressed.
And that just about does it. It seems to be working just fine for me, and I would appreciate any optimizations or improvements, as well as bugs so that I can get it working even better!
But it does achieve a "Double Jump" mechanic
FIRST, we need to make two vars:
These will be in SystemVariables.asm
Code:
canDoubleJump .dsb 1 ; This will be set AFTER we jump, otherwise it's not really a double jump is it.
didDoubleJump .dsb 1 ; Keep in mind when looking at this in code, it is a REVERSE boolean
Then we look at the new Jump Script...
I named this playerDoubleJump.asm, and I assigned it to the hold "A" input
Code:
LDX player1_object
LDA Object_status,x
AND #%00000100
BEQ +
LDA #$00
SEC
SBC #$06
STA Object_v_speed_hi,x
LDA Object_status,x
AND #%11111011
STA Object_status,x
ChangeObjectState #$02, #$02
LDA #$00
STA canDoubleJump ; We cant double jump until AFTER we release, so this will come up again on the release script
LDA #$01
STA didDoubleJump ; Remember how I said I used this like a reverse boolean? don't worry, we didn't double jump yet!
PlaySound #SFX_PLAYER_JUMP
+
RTS
Next, we look at the release script, which is also VERY similar to the original,
I named mine varPlayerDoubleJumpRelease.asm, and you guessed it! It is called on "A"'s release
Code:
LDA #$01
STA canDoubleJump ; Lets set this now, so we can do it.
LDA #$00 ; Its always good to start at 0
SEC
SBC #$02 ; I chose 2 over the tutorials 3 because I wanted lighter/tighter jumps
LDX player1_object
CMP Object_v_speed_hi,x ; Rather than BPL, we will compare with the current player value
BMI skipVarJump ; If the speed is below the jumping (reverse falling speed)
LDA #$00 ; the same fun way to set the values as the original lol.
SEC
SBC #$02 ; This should be the same as we compare against above
STA Object_v_speed_hi,x
skipVarJump:
RTS
Now, we set a new script, this one I called: playerDoubleJumpPress.asm
I use it when the "A" button is pressed.
Code:
LDA canDoubleJump ; Can we double jump?
BEQ +
LDA didDoubleJump ; Did we already do a double jump?
BEQ +
LDA Object_status,x
AND #%00000100 ; Remember the check in the jump script? this one works similar, but makes sure we are NOT on the ground
BNE +
LDA #$00
STA didDoubleJump
LDA #$00
STA canDoubleJump
LDA #$00
SEC
SBC #$04 ; I went for a lower value than the initial jump... but you can alter the height of it here.
LDX player1_object
STA Object_v_speed_hi,x
LDA Object_status,x
AND #%11111011
STA Object_status,x
ChangeObjectState #$02, #$02
+
RTS
And that just about does it. It seems to be working just fine for me, and I would appreciate any optimizations or improvements, as well as bugs so that I can get it working even better!