Megaman Style slide/dash code issue

Having trouble compiling code? Getting an unexpected error? Player not appearing on screen? Seeking answers on how to do a particular thing? This is the forum you're looking for, to ask other NESmaker users for assistance.
Post Reply
User avatar
chronicleroflegends
Posts: 100
Joined: Thu Sep 06, 2018 3:51 am

Megaman Style slide/dash code issue

Post by chronicleroflegends » Fri Sep 07, 2018 6:03 pm

I am trying to make a megaman style slide/dash action script, and it almost works just right!

I am having trouble determining the player's facing direction however.

Here is what I have so far:

Code: Select all

;; MODIFIED FROM DEFAULT JUMP SCRIPT

;; Get player object
;; Check if in air, and skip if so.
LDX player1_object
LDA Object_status,x
AND #%00000100
BEQ +

;; Check facing direction
LDA Object_movement,x
AND #%00000111 ;only keep the last 3 bits
CMP #$00000110 ;facing right
BEQ slideRight
JMP slideLeft

slideRight:
;FACE_RIGHT		= #%00000010
LDA #$00
SEC
ADC #$03  
STA Object_h_speed_hi,x

slideLeft:
;FACE_LEFT		= #%00000110
;; Store 250 in accumulator and assign it to object's speed
LDA #$00
SEC
SBC #$03  
STA Object_h_speed_hi,x

ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
;PlaySound #SFX_PLAYER_JUMP
+
RTS
This code will dash, but it will only go left. My check for player's facing direction doesn't seem to work.
Also, if this code helps you in any way feel free to use it!
~Do you believe in legends? ~
My Games: Nix: The Paradox Relic [WIP]
User avatar
dale_coop
Posts: 2561
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Megaman Style slide/dash code issue

Post by dale_coop » Fri Sep 07, 2018 7:36 pm

A small corrected script:

Code: Select all

;; MODIFIED FROM DEFAULT JUMP SCRIPT

;; Get player object
;; Check if in air, and skip if so.
	LDX player1_object
	LDA Object_status,x
	AND #%00000100
	BEQ +

	;; Check facing direction
	LDA Object_movement,x
	AND #%00000111 ;only keep the last 3 bits
	CMP #%00000010 ;FACE_RIGHT		= #%00000010
	BEQ slideRight
	JMP slideLeft

slideRight:
	;FACE_RIGHT		= #%00000010
	LDA #$00
	ADC #$06
	STA Object_h_speed_hi,x
	JMP continueSliding

slideLeft:
	;FACE_LEFT		= #%00000110
	;; Store 250 in accumulator and assign it to object's speed
	LDA #$00
	SBC #$06
	STA Object_h_speed_hi,x

continueSliding:
	ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
	;PlaySound #SFX_PLAYER_JUMP
+
	RTS
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
User avatar
chronicleroflegends
Posts: 100
Joined: Thu Sep 06, 2018 3:51 am

Re: Megaman Style slide/dash code issue

Post by chronicleroflegends » Fri Sep 07, 2018 8:20 pm

Thank you! That got it working perfectly.

I see the two typos I had now.
~Do you believe in legends? ~
My Games: Nix: The Paradox Relic [WIP]
digitalbooty
Posts: 36
Joined: Fri Oct 19, 2018 7:42 pm

Re: Megaman Style slide/dash code issue

Post by digitalbooty » Mon Nov 12, 2018 3:48 am

I used the corrected code, mine only dashes left, too. I've assigned it to press "Down" on the d-pad. Should I put this code elsewhere?
User avatar
dale_coop
Posts: 2561
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Megaman Style slide/dash code issue

Post by dale_coop » Mon Nov 12, 2018 7:08 am

You can’t assign it to “down” because the script will not know which direction your player want to go.
You need to assign it to “left” and to “right”.
And in your case it you want the player to dash only if press “down” at the same time, you might modify the script to check the gamepad, maybe something like that:

Code: Select all

;; MODIFIED FROM DEFAULT JUMP SCRIPT

;; Get player object
;; Check if in air, and skip if so.
	LDX player1_object
	LDA Object_status,x
	AND #%00000100
	BEQ +
	
	LDA gamepad
	CMP #%00100000  ;;check if “down” is press too
	BNE +

	;; Check facing direction
	LDA Object_movement,x
	AND #%00000111 ;only keep the last 3 bits
	CMP #%00000010 ;FACE_RIGHT		= #%00000010
	BEQ slideRight
	JMP slideLeft

slideRight:
	;FACE_RIGHT		= #%00000010
	LDA #$00
	ADC #$06
	STA Object_h_speed_hi,x
	JMP continueSliding

slideLeft:
	;FACE_LEFT		= #%00000110
	;; Store 250 in accumulator and assign it to object's speed
	LDA #$00
	SBC #$06
	STA Object_h_speed_hi,x

continueSliding:
	ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
	;PlaySound #SFX_PLAYER_JUMP
+
	RTS
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
digitalbooty
Posts: 36
Joined: Fri Oct 19, 2018 7:42 pm

Re: Megaman Style slide/dash code issue

Post by digitalbooty » Mon Nov 12, 2018 5:41 pm

I see. That makes sense. I'm slowly, but surely starting to get acclimated to ASM. Thanks
User avatar
dale_coop
Posts: 2561
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Megaman Style slide/dash code issue

Post by dale_coop » Mon Nov 12, 2018 7:20 pm

Ah ah don’t worry, we all are learning here ;)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE
User avatar
Electric cat
Posts: 44
Joined: Sun Oct 07, 2018 4:09 am

Re: Megaman Style slide/dash code issue

Post by Electric cat » Tue Feb 12, 2019 6:25 am

So then you would make 2 new scripts dash.asm and stopdash.asm? And then place this in the input scripts and the assign them to the left dash right dash? But what if you want the dash to happen when you press A button and left or right? Where do you change the code for that to happen

Cheers
Post Reply