I want to be able to heal myself with the press of a button, using ammo. I've done this sorta successfully in 2 different ways, but I'm having a problem doing it the way that I want to. The code is below, but I wanna give you a little background.
1st I just put my health pickup code in one of my button inputs. It worked! But when I added ammo code/ammo HUD update it got all messed up.
2nd, I just created a health pickup the same way you would create a weapon object. Success, and the HUD updates right. But it's weird, and I just wanna heal without creating an object and part of the point of this was to free up powerup objects.
3rd (where I am right now), I put the health pickup code back into the button input, like in my first scenario, and then used slightly different code for the HUD update. This ammo HUD updates properly, but when I add the health HUD update, in acts all kinds of crazy. Taking hearts away and just not updating the ammo HUD.
Basically, it seems like maybe I don't know what's going on :roll:
Here's the code, any help is much appreciated. So glad to have to forums back.
1st I just put my health pickup code in one of my button inputs. It worked! But when I added ammo code/ammo HUD update it got all messed up.
2nd, I just created a health pickup the same way you would create a weapon object. Success, and the HUD updates right. But it's weird, and I just wanna heal without creating an object and part of the point of this was to free up powerup objects.
3rd (where I am right now), I put the health pickup code back into the button input, like in my first scenario, and then used slightly different code for the HUD update. This ammo HUD updates properly, but when I add the health HUD update, in acts all kinds of crazy. Taking hearts away and just not updating the ammo HUD.
Basically, it seems like maybe I don't know what's going on :roll:
Here's the code, any help is much appreciated. So glad to have to forums back.
Code:
specialMove2:
LDA gameHandler
AND #%00100000
BEQ notNPCstate_attack3
JMP doneHealing
notNPCstate_attack3:
LDA weaponsUnlocked
AND #%00000010
BNE canHeal
JMP doneHealing
canHeal:
LDX player1_object
;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 3 lines:
;;; check if already shooting (assuming the shoot action step is 05)
GetCurrentActionType player1_object
CMP #$03
BNE notAlreadyHealing
JMP checkIfCanHeal
notAlreadyHealing:
;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 1 line:
;;; if not already shooting, change it's action step (assuming the shoot action step is 05)
ChangeObjectState #$03, #$02
;;; if you want your player stops when he's shooting, comment out the following lines:
LDA Object_movement,x
AND #%00001111
STA Object_movement,x
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
;; if was already shooting
checkIfCanHeal:
;; will check if the weapon is charged (if Ammo > 2) :
LDA myAmmo
CMP #$03
BCS continueHealing ;; if greater than 2
;;if no Ammo, we're done here.
RTS
;; if enought Ammo we can continue shooting:
continueHealing:
LDA myHealth
CLC
ADC #$01
CMP #$06 ;; <--- HERE the max health limit you can NOT reach (means if your max health is 8, here is 9)
BCS doneHealing
TXA
STA tempx
;;;you may want to test against a MAX HEALTH.
;;; this could be a static number in which case you could just check against that number
;;; or it could be a variable you set up which may change as you go through the game.
inc myHealth
LDA myHealth
LDX player1_object
STA Object_health,x
;HEALTH HUD UPDATE
STA hudElementTilesToLoad
LDA #$00
STA hudElementTilesMax
; LDA DrawHudBytes
; ORA #HUD_myHealth
; STA DrawHudBytes
UpdateHud HUD_myHealth
LDX tempx
;;;;;;;;;;;;;;;;;
;; start Updating Ammo
LDA myAmmo
SEC
SBC #03
STA myAmmo
;;; we also need to set up the routine to update the HUD
;; for this to work right, health must be a "blank-then-draw" type element.
STA hudElementTilesToLoad
LDA #$00
STA hudElementTilesMax
UpdateHud HUD_myAmmo
;; finished Updating Ammo
;PlaySound #SND_SHOOT
doneHealing:
RTS