Lets try to Double Jump!

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

Lets try to Double Jump!

Post by WolfMerrik » Sat Sep 01, 2018 4:46 pm

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

Code: Select all

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: Select all

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: Select all

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: Select all

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!
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: Lets try to Double Jump!

Post by WolfMerrik » Sat Sep 01, 2018 5:07 pm

All three files can be downloaded at these pages:
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: Lets try to Double Jump!

Post by WolfMerrik » Sat Sep 01, 2018 5:10 pm

You could also make an action state for this as well (like a forward flip?)
To do this, you would change the state value in playerDoubleJumpPress.asm

This could be a way to make a mechanic like the "Screw Attack" in the Metroid games, you could essentially make this into an attack
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
CutterCross
Posts: 402
Joined: Sat Apr 28, 2018 9:42 pm
Contact:

Re: Lets try to Double Jump!

Post by CutterCross » Sat Sep 01, 2018 5:14 pm

Awesome! Would love to see something like a wall-jump script in the future. Sadly I don't have the chops to code that myself yet.
Music Man:
The Tower of Turmoil: http://www.nesmakers.com/viewtopic.php?f=12&t=1348
When the Clock Hands Stall: http://www.nesmakers.com/viewtopic.php?f=52&t=2723
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: Lets try to Double Jump!

Post by WolfMerrik » Sat Sep 01, 2018 5:23 pm

CutterCross wrote:
Sat Sep 01, 2018 5:14 pm
Awesome! Would love to see something like a wall-jump script in the future. Sadly I don't have the chops to code that myself yet.
Ooooo! I want that too!
I was going to look at fixed direction jumps next (like Castlevania etc)
But this could be a lot more fun!
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: Lets try to Double Jump!

Post by WolfMerrik » Sat Sep 01, 2018 5:29 pm

If you wanted, you could also make it so you can only double jump BEFORE your jump has reached the apex and you are falling:

You would change varPlayerDoubleJumpRelease.asm like this:

Code: Select all

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
LDA #$01
STA canDoubleJump		; Lets set this here, so we cant double jump if we are already falling down
skipVarJump:			; No jump.... no thanks
RTS
This makes it so you can miss the opportunity to double jump, which would be a fun choice for this mechanic.
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
Bucket Mouse
Posts: 344
Joined: Wed Mar 07, 2018 2:25 am

Re: Lets try to Double Jump!

Post by Bucket Mouse » Sat Sep 01, 2018 7:36 pm

Can you try to make these topics in the Code forum, or at least double-post them there? They'll get buried here since people don't search this particular subforum to look for good plug-in ASM.
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: Lets try to Double Jump!

Post by WolfMerrik » Sat Sep 01, 2018 8:54 pm

Bucket Mouse wrote:
Sat Sep 01, 2018 7:36 pm
Can you try to make these topics in the Code forum, or at least double-post them there? They'll get buried here since people don't search this particular subforum to look for good plug-in ASM.
I suppose that is not a bad idea, and it is done.
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: Lets try to Double Jump!

Post by WolfMerrik » Sun Sep 02, 2018 12:22 am

There does seem to be a "bug" or at the very least something that player could exploit; When a player is falling, if they did not use the "DoubleJump" it can be used.
I would assume the best way to fix this would be to add:

Code: Select all

	LDA #$00	;;Set the ability to Double Jump to 0;
	STA canDoubleJump 
When the player hits the ground.
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
User avatar
WolfMerrik
Posts: 199
Joined: Sat Aug 11, 2018 4:59 pm
Location: Maine
Contact:

Re: Lets try to Double Jump!

Post by WolfMerrik » Sun Sep 02, 2018 12:33 am

WolfMerrik wrote:
Sun Sep 02, 2018 12:22 am
There does seem to be a "bug" or at the very least something that player could exploit; When a player is falling, if they did not use the "DoubleJump" it can be used.
I would assume the best way to fix this would be to add:

Code: Select all

	LDA #$00	;;Set the ability to Double Jump to 0;
	STA canDoubleJump 
When the player hits the ground. You could even put this on the Change to walking/idle animation scripts.
ImageWant to download & share Image NESMaker Resources? Check out My Files on www.NESMakerFiles.com Image
Post Reply