(4.5.9) Monster/Player HUD Health Bar help?

PewkoGames

Member
;;;;;;;;;;;;;;;;;; Presumes there is a variable called myLives defined in user variables.
;;;;;;;;;;;;;;;;;; You could also create your own variable for this.

LDA gameHandler
AND #%10000000
BEQ +canHurtPlayer
JMP +skipHurt

+canHurtPlayer:
; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ;;;;;;;;;; is the monster below our feet?
; ;;;;;;;;;; and are we moving downward?

LDA Object_v_speed_hi,x
BPL + ;; if it's positive then go to +
JMP +doHurtPlayer
;; if it's negative or equal
+
TXA
PHA
LDX otherObject
TXA
STA temp
GetActionStep temp
CMP #$06 ;; we will use action step 7 for hurt.
BEQ +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
ChangeActionStep temp, #$06
DEC bossHealth
UpdateHudElement #$04
DEC Object_health,x
LDA Object_health,x
BNE +doSkipHurtingThisObject
TriggerScreen screenType
DestroyObject

+doSkipHurtingThisObject
PLA
TAX
;DestroyObject
; PLA
; TAX

; ;; Do a hop
LDA #$FC
STA Object_v_speed_hi,x


JMP +skipHurt
+doHurtPlayer


TXA
STA temp
GetActionStep temp
CMP #$06
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
;;; will presume there is a variable myHealth
;;; and that player hurt state is action state 7.
GetActionStep player1_object
CMP #$06 ;; hurt state.
BEQ +notAlreadyInHurtState
DEC myHealth

BMI +healthBelowZero
BEQ +healthBelowZero
JMP +notDeadYet
+healthBelowZero

JMP +playerHealthIsZero
+notDeadYet
UpdateHudElement #$06
ChangeActionStep player1_object, #$06
;; 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:

LDA continueMap
STA warpMap

LDA continueX
STA newX
LDA continueY
STA newY

LDA continueScreen
STA warpToScreen
STA camScreen


LDA myMaxHealth
STA myHealth


+doHurtPlayer
LDA Object_direction,x
AND #%00001111
STA Object_direction,x

Dec myLives
LDA myLives
BNE myLivesNotZero
JMP RESET ;; game over.
;;;; also could warp to game over screen here instead.
myLivesNotZero:
ChangeActionStep player1_object, #$07
;StopSound
;PlaySound #sfx_playerdead

;LDA continueMap
;STA warpMap

;LDA continueScreen
;STA currentNametable
;AND #%00001111
;STA camX_hi

;LDX player1_object
;STA Object_screen,x

;LDA #$02 ;; this is continue type warp.
;STA screenTransitionType ;; is of warp type


;LDA #$00
;STA camX

;LDA gameHandler
;ORA #%10000000
;STA gameHandler ;; this will set the next game loop to update the screen.

+skipHurt

So I'm trying to figure Out having a health bar for my monster and player in the HUD of the Arcade Platform Module. So far its NEARLY working but my biggest issue is this: When I jump on the enemy head, it works as expected. The monster takes 1 hit, a segment of the health is removed from his healthbar in the HUD and it plays a Hurt animation. The issue comes when the monster runs into the player. Both the player and the monster take damage when colliding and I just want the player to take damage.

Thats the biggest problem. There is another issue I'm having where when I take out the monster, the death animation of the monster doesen't play he just vanishes. I put in a ChangeActionStep temp, #$07 (#$07 is my monster death animation) but when I add that in, it plays my PLAYER death animation instead. Something must be confusing the two. If anyone can help that would be great!
 

Attachments

  • game_033.png
    game_033.png
    4.8 KB · Views: 7

dale_coop

Moderator
Staff member
Try replacing your "DestroyObject" with a "ChangeActionStep temp, #$07"... now your monster should not disappear.

....and maybe you will have to change your:
Code:
CMP #$06 ;; we will use action step 7 for hurt.
BEQ +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
Into:
Code:
CMP #$06 ;; we will use action step 7 for hurt.
BCS +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
 

PewkoGames

Member
So I tried the change action step 7 but it didin't work. Now the Monster doesen't die or dissapear. Also switch ing BEQ to BCS didin't do anything.
 

dale_coop

Moderator
Staff member
Now, your monters goes to his death state (action step 7)... (and no more destroyed)
So you need to set the action step 7 to play the animation and at the end of animation (or end timer) set it to "DestroyMe".
 
Top Bottom