Adventure Module - Help! Weapon Animation Only Shows Down State!

mingus.

New member
I will admit, I am relatively new to assembly code. I started an Adventure Module-based game recently, and I have been trying to get a sword-esque attack working. When the attack is used, I want the sword to face away from the player as you may expect. However, whenever I use the attack, the weapon faces down? Every time?
Here is a section of the code I have for "ChangeToAttack_AdventureBase":
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Now, we have to create the object.
;; We will need to determine the direction
;; of the player.
LDX player1_object
TXA
STA temp
GetObjectDirection temp ;; temp still observed from above.
;;; this object's direction is now loaded into the
;;; accumulator for comparison after the macro.
;; 0 = down
;; 1 = downright
;; 2 = right
;; 3 = upright
;; 4 = up
;; 5 = upleft
;; 6 = left
;; 7 = downleft
BNE +notDown ;; jump if not equal to zero.
;;; CREATE DOWN WEAPON
;;; create an object for the weapon.
;;; create it at the down positions.
;;; create it with the down state

LDX player1_object
LDA Object_x_hi,x
CLC
ADC #WEAPON_POSITION_DOWN_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_POSITION_DOWN_Y
STA tempB
LDY weaponChoice
LDA weaponObjectTable,y
STA tempC
;; use this is you want to always create a single object, based on
;; the constant above.
; CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_DOWN_STATE, currentNametable

;;; use this if you want to create a variable object based on
;;; the weaponChoice varaible.
CreateObject tempA, tempB, tempC, #WEAPON_DOWN_STATE, currentNametable ;originally tempC after tempB

LDA #%00110000
STA Object_direction,x
JMP +doneWithCreatingWeapon
+notDown
CMP #$02
BNE +notRight
;;; CREATE RIGHT WEAPON
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #WEAPON_POSITION_RIGHT_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_POSITION_RIGHT_Y
STA tempB
LDY weaponChoice
LDA weaponObjectTable,y
STA tempC
;; use this is you want to always create a single object, based on
;; the constant above.
; CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_RIGHT_STATE, currentNametable

;;; use this if you want to create a variable object based on
;;; the weaponChoice varaible.
CreateObject tempA, tempB, tempC, #WEAPON_RIGHT_STATE, currentNametable
LDA #%11000000
STA Object_direction,x
JMP +doneWithCreatingWeapon
+notRight
CMP #$04
BNE +notUp
;;; CREATE UP WEAPON
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #WEAPON_POSITION_UP_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_POSITION_UP_Y
STA tempB
LDY weaponChoice
LDA weaponObjectTable,y
STA tempC
;; use this is you want to always create a single object, based on
;; the constant above.
; CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_DOWN_STATE, currentNametable

;;; use this if you want to create a variable object based on
;;; the weaponChoice varaible.
CreateObject tempA, tempB, tempC, #WEAPON_UP_STATE, currentNametable
LDA #%00100000
STA Object_direction,x
JMP +doneWithCreatingWeapon
+notUp
CMP #$06
BNE +notLeft
;;; CREATE LEFT WEAPON
LDX player1_object
LDA Object_x_hi,x
CLC
ADC #WEAPON_POSITION_LEFT_X
STA tempA
LDA Object_y_hi,x
CLC
ADC #WEAPON_POSITION_LEFT_Y
STA tempB

LDY weaponChoice
LDA weaponObjectTable,y
STA tempC
;; use this is you want to always create a single object, based on
;; the constant above.
; CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_DOWN_STATE, currentNametable

;;; use this if you want to create a variable object based on
;;; the weaponChoice varaible.
CreateObject tempA, tempB, tempC, #WEAPON_LEFT_STATE, currentNametable
LDA #%10000000
STA Object_direction,x
JMP +doneWithCreatingWeapon
+notLeft

+doneWithCreatingWeapon

RTS

weaponChoiceTable:
.db #%00000001, #%00000010, #%00000100, #%00001000
.db #%00010000, #%00100000, #%01000000, #%10000000


weaponObjectTable:
.db #$01, #$06, #$03, #$03, #$03, #$03, #$03, #$03
As well here is a screenshot of my issue:
Arrows.jpg
The arrows are current placeholders and all face down. They should face away?

Not sure what's going on here. I assumed that the code of "#WEAPON_LEFT_STATE" or RIGHT_STATE and otherwise would change the direction/animation of the object.
Does anybody know how to fix this?
 

dale_coop

Moderator
Staff member
In that module, the “normal” object facing is not used for the weapon object. Instead, each “Action Step” corresponds to a facing direction.
Action Step 0 is for “DOWN”
Action Step 1 is for “DOWN RIGHT”
Action Step 2 is for “RIGHT”
...
Action Step 7 is for “DOWN LEFT”

So, you need to create as many “Animation Types” as you have facing-direction animations, and assign them accordingly.
 

mingus.

New member
I see. I was just using one action step (the first one, so that's why it was always down) with a different animation attempting to play depending on the direction.
This fixed it, thank you!
 
Top Bottom