[4.1.5] 8 Directional Movement

Saulus_Lira

Member
dale_coop said:
Share your script (StartMovingPlayerDown), we can check if there's a error ;)

Also, when you share script on the forum, use the < code /> tag (in the "Full Editor & Preview")


Sorry for the delay to reply. Here goes the code.

;;;;; START MOVING PLAYER UP:
;;;;; We will use this when the up button is pressed.
;;;;; If we are already showing the walking animation, which is for this module
;;;;; action step 1, we will skip changing to the walking state.
LDA Object_movement,x
AND #%00000111
CMP #%00000100
BCS +
LDA #FACE_RIGHT
STA temp2
JMP ++
+
LDA #FACE_LEFT
STA temp2
++
LDX player1_object
GetCurrentActionType player1_object
CMP #$02 ;; if the state is attacking
BEQ ++ ; skip movement if attacking
CMP #$03
BEQ ++ ;skip if we are casting spell
CMP #$01
BEQ + ;; if the action type already equals 1, jump forward
ChangeObjectState #$01, #$04
+
;;;;;; Then, we will begin moving.
StartMoving player1_object, MOVE_UP
++
;;;;;; Lastly, we will change the facing direction.
FaceDirection player1_object, temp2
RTS


;;;;; START MOVING PLAYER DOWN:
;;;;; We will use this when the up button is pressed.
;;;;; If we are already showing the walking animation, which is for this module
;;;;; action step 1, we will skip changing to the walking state.
LDA Object_movement,x
AND #%00000111
CMP #%00000100
BCS +
LDA #FACE_RIGHT
STA temp2
JMP ++
+
LDA #FACE_LEFT
STA temp2
++
LDX player1_object
GetCurrentActionType player1_object
CMP #$02 ;; if the state is attacking
BEQ ++ ; skip movement if attacking
CMP #$03
BEQ ++ ;skip if we are casting spell
CMP #$01
BEQ + ;; if the action type already equals 1, jump forward
ChangeObjectState #$01, #$04
+
;;;;;; Then, we will begin moving.
StartMoving player1_object, MOVE_DOWN
++
;;;;;; Lastly, we will change the facing direction.
FaceDirection player1_object, temp2
RTS
 

dale_coop

Moderator
Staff member
Ok...
then instead of the line:
Code:
	FaceDirection player1_object, temp2

Try, replacing with:
Code:
	LDA Object_movement,x
	AND #%11111000
	ORA temp2
	STA Object_movement,x
 

Saulus_Lira

Member
dale_coop said:
Ok...
then instead of the line:
Code:
	FaceDirection player1_object, temp2

Try, replacing with:
Code:
	LDA Object_movement,x
	AND #%11111000
	ORA temp2
	STA Object_movement,x

Once again, thank you very much Dale_Coop.
I'll try this when I get home from work. :D
With everything going well, I will insert some enemies and make the rom available to see how it got here.
 

vanderblade

Active member
I'm using the correct Input Script Order, and I've done all I can, and I still feel like the 8-way movement isn't as good as it was in 4.1.5. Why is that? Does anyone else feel like 8-way movement in the latest version of NESMaker just doesn't feel as good?
 

baardbi

Well-known member
I made a few new input scripts for the shooter module. They seem to work fine.

MoveUpLeft:
;;;;
TXA
STA temp ;; assumes the object we want to move is in x.

StartMoving temp, #UPLEFT
TXA
STA temp
ChangeFacingDirection temp, #FACE_UPLEFT

RTS

MoveUpRight:
;;;;
TXA
STA temp ;; assumes the object we want to move is in x.

StartMoving temp, #UPRIGHT
TXA
STA temp
ChangeFacingDirection temp, #FACE_UPRIGHT

RTS

MoveDownLeft:
;;;;

TXA
STA temp ;; assumes the object we want to move is in x.

StartMoving temp, #DOWNLEFT
TXA
STA temp
ChangeFacingDirection temp, #FACE_DOWNLEFT

RTS

MoveDownRight:
;;;;

TXA
STA temp ;; assumes the object we want to move is in x.

StartMoving temp, #DOWNRIGHT
TXA
STA temp
ChangeFacingDirection temp, #FACE_DOWNRIGHT

RTS
 
Top Bottom