Health Tile

I made a health tile basically just by copying and pasting the heathdrop code into a blank tile script.

I don't know if i actually need the "ChangeTileAtCollision #$00, #$00" at the end, but figured it's in other "pickup" tile types so...

Does any one know how to make it so that it adds more than one health? the only variable in here I can think of that would/could do that is ADC but changing that didn't do anything.

Code:
;; COLLECTABLE - this tile requires 
;; HUD to be active and for myScore variable to be drawn.
;; To use this without this feature, comment out lines marked below.

;;; Increase Health code for player.
;;; works with variable myHealth
;;; works with HUD variable HUD_myHealth.
	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 skipGettingHealth
	
	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

	;;; 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
		; LDA DrawHudBytes
		; ORA #HUD_myHealth
		; STA DrawHudBytes
	UpdateHud HUD_myHealth
	LDX tempx
	
skipGettingHealth:
	;PlaySound #SFX_INCREASE_HEALTH

	ChangeTileAtCollision #$00, #$00
 

dale_coop

Moderator
Staff member
If you want more than 1 life... instead of
Code:
	inc myHealth
(that just increase by one the health variable)
you could use
Code:
	LDA myHealth
	ADC #$02	;; <<-- add 2 
	STA myHealth

or maybe a :
Code:
	inc myHealth
	inc myHealth
(..increasing twice) would work too.
 
Ok thanks. I tried changing the ADC to #$03 but it didn't seem to do anything. I"ll try your other way :)

Just checked and duplicating "inc myHealth worked!!!
 
Top Bottom