JFranco
New member
Good afternoon,
I'm having a slight issue with my player's health:
I can set the Game Object's Health to '99', and I can set the myHealth initial value to '99' (and it appears in the HUD properly - it's presented in numerical format).
However, as soon as I start taking damage from enemies (keep in mind, they are only doing 1 damage per hit), when my player's health drops to '90', the game is over.
I'm guessing the code I need to modify is in here -- HandlePlayerHurt.ASM -- within the first few lines of code. Note: Most comments are mine.
What's throwing me off is:
How do I correct this so that I can have 2 digits (ex: '99') or even 3 digits of health (ex: '200') and have it subtract properly down to zero?
Thanks,
Justin
I'm having a slight issue with my player's health:
I can set the Game Object's Health to '99', and I can set the myHealth initial value to '99' (and it appears in the HUD properly - it's presented in numerical format).
However, as soon as I start taking damage from enemies (keep in mind, they are only doing 1 damage per hit), when my player's health drops to '90', the game is over.
I'm guessing the code I need to modify is in here -- HandlePlayerHurt.ASM -- within the first few lines of code. Note: Most comments are mine.
Code:
;; This works for single digit health. Player dies at when the 1s hit zero.
LDA Object_health,x ;load player's new health into accumulator?
CLC ;clear the carry
SEC ;; clear the carry (again ?)
SBC #$01 ;; subtract other's strength
CMP #$01 ;; compare to #$01
BCS notPlayerDeath ;; branch to notPlayerDeath if X >= #$01
JSR HandlePlayerDeath ;if Player Dead, jump to HandlePlayerDeath subroutine
JMP doneWithPlayerHurt
What's throwing me off is:
Code:
SBC #$01 ;; subtract other's strength
How do I correct this so that I can have 2 digits (ex: '99') or even 3 digits of health (ex: '200') and have it subtract properly down to zero?
Thanks,
Justin