CutterCross
Active member
I've been at this for a couple hours and I can't seem to find a solution...
Whenever the player dies and his health is supposed to be 0, his health stays at 1 and doesn't decrease. This is the only instance of this issue happening.
I've tried manually setting the myHealth variable to 0 in HandlePlayerDeath.asm, but it instead gets set to 0 AFTER the game restarts again.
I've also tried manually setting it to 0 in HandlePlayerHurt.asm, but that did nothing.
I'm kind of at a loss here...
Whenever the player dies and his health is supposed to be 0, his health stays at 1 and doesn't decrease. This is the only instance of this issue happening.
I've tried manually setting the myHealth variable to 0 in HandlePlayerDeath.asm, but it instead gets set to 0 AFTER the game restarts again.
Code:
HandlePlayerDeath:
LDA #$00 ;Trying to set myHealth to 0
STA myHealth ;
TXA
STA tempx
TYA
STA tempy
;;;;;;;;;;;;;;;;;;;
LDX player1_object
LDA Object_x_hi,x
STA temp
LDA Object_y_hi,x
STA temp1
CreateObject temp, temp1, #$08, #$00
;; need to do this redundantly, otherwise, the death object will be in same slot as player
LDA #$00
SEC
SBC #$05
STA Object_v_speed_hi,x
LDX player1_object
DeactivateCurrentObject
;;;;;;;;;;;;;;;;;;;
;StopSound
PlaySound #SFX_PLAYER_LOSE
LDA #$FF
STA player1_object
LDX tempx
LDY tempy
RTS
I've also tried manually setting it to 0 in HandlePlayerHurt.asm, but that did nothing.
Code:
;;; assumes myHealth variable
;;; if a different variable should handle health
;;; change thename of myHealth.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; uses timers set in GameData\Constants:
;;OBJECT TIMERS
;HURT_TIMER = #$08
;INVINCIBILITY_TIMER = #$08
;RECOIL_SPEED_HI = #$06
;RECOIL_SPEED_LO = #$00
;;;; To change invincibility time, knock back speed, or hurt duration
;;;; updating the above values in constants
LDA Object_status,x
ORA #%00000001
STA Object_status,x
LDA #HURT_TIMER
STA Object_timer_0,x
ChangeObjectState #$05,#$02 ;;hurt state.
LDA selfCenterX
STA recoil_selfX
LDA selfCenterY
STA recoil_selfY
LDA otherCenterX
STA recoil_otherX
LDA otherCenterY
STA recoil_otherY
JSR DetermineRecoilDirection
LDA Object_health,x
SEC
SBC #$01 ;; subtract other's strength
CMP #$01
BCS notPlayerDeath
LDA #$00 ;Trying to set myHealth to 0 when player dies.
STA myHealth ;
JSR HandlePlayerDeath
JMP doneWithPlayerHurt
notPlayerDeath:
STA Object_health,x
STA myHealth
STA hudElementTilesToLoad
LDA #$00
STA hudElementTilesMax
LDA DrawHudBytes
ora #HUD_myHealth
STA DrawHudBytes
;; TURN ON handling the hud
PlaySound #SFX_PLAYER_DAMAGE
doneWithPlayerHurt:
I'm kind of at a loss here...