(4.5.9) Arcade Platformer Player/Monster health bars

PewkoGames

Member
So I'm working on a boxing/wrestling themed game. I'm using the arcade platformer module and I want it so that, when the monster takes a hit, it loses one bar off of his health meter in the Hud. Same with the player:

Right now, I had it so that the player took damage, when the player ran out of health he lost a life and so on. THAT was working fine. The only problem was I could not hurt the monster. I tried to make it so I can at least hurt the monster. I got close I think but now nobody takes damage.

Here's the code I'm working with in the hurt player arcade platfromer.asm

Can anyone help?

;;;;;;;;;;;;;;;;;; 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 Object_health,x
LDA Object_health,x
BNE +doSkipHurtingThisObject
TriggerScreen screenType
ChangeActionStep temp, #$07
+doSkipHurtingThisObject
PLA
TAX
;DestroyObject
; PLA
; TAX

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


JMP +skipHurt

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
 

Attachments

  • game_033.png
    game_033.png
    4.8 KB · Views: 14
  • game_032.png
    game_032.png
    4.8 KB · Views: 15
Top Bottom