5kids2feed
Well-known member
Question. I made a hurt tile for my game (which is essentially a copy of my hurt player script), but no matter which way I walk into the tile, I always recoil to the right... when in my hurt player script I recoil correctly. Anyone else have this issue?
Here's the basic idea of what I got. Does it has something to do with the tile collision and not the code here?
Here's the basic idea of what I got. Does it has something to do with the tile collision and not the code here?
Code:
CPX player1_object
BEQ +continue
LDA ObjectUpdateByte
ORA #%00000001
STA ObjectUpdateByte ;; makes solid
RTS
+continue:
TXA
STA temp
GetActionStep temp
CMP #$07
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
CMP #$06
BNE +canHurtPlayer2
JMP +skipHurt
+canHurtPlayer2
;;; will presume there is a variable myHealth
;;; and that player hurt state is action state 7.
GetActionStep player1_object
CMP #$07 ;; hurt state.
BEQ +notAlreadyInHurtState
PlaySound #4
DEC myHealth
BMI +healthBelowZero
BEQ +healthBelowZero
JMP +notDeadYet
+healthBelowZero
JMP +playerHealthIsZero
+notDeadYet
UpdateHudElement #$02
ChangeActionStep player1_object, #$07
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
LDA xPrev
STA Object_x_hi,x
LDA yPrev
STA Object_y_hi,x
+notAlreadyInHurtState
LDA Object_x_hi,x
CLC
ADC self_center_x
STA tempA
LDA Object_y_hi,x
CLC
ADC self_center_y
STA tempB
TXA
PHA
LDX otherObject
LDA Object_x_hi,x
CLC
ADC other_center_x
STA tempC
LDA Object_y_hi,x
CLC
ADC other_center_y
STA tempD
PLA
TAX
;;; RECOIL L/R
;+recoilHor
LDA tempA
CMP tempC
BCS +recoilRight
LDA Object_direction,x
AND #%00001111
ORA #%10000000
STA Object_direction,x
JMP +skipHurt
+recoilRight
LDA Object_direction,x
AND #%00001111
ORA #%11000000
STA Object_direction,x
JMP +skipHurt
+playerHealthIsZero:
ChangeActionStep player1_object, #06
+skipHurt
RTS