Health WTF

darkhog

New member
I... really don't know what I did wrong. Just look at this: https://youtu.be/tB0YpU2Uj1o

It happens both when player get hurt and healed in my game. This is my health powerup script. The only thing I've changed was the max health comparison value. No idea what's wrong but it also happens when player gets hurt. Doesn't happen if the health is displayed as a number.

Code:
;;; Increase Health code for player.
;;; works with variable myHealth
;;; works with HUD variable HUD_myHealth.
	LDA myHealth
	CLC
	;ADC #$01
	CMP #$06
	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

	LDX tempx

skipGettingHealth:
	PlaySound #sfx_1up
 

drexegar

Member
Its been a while, but I have the same problem to, all I did was just move my health bar higher in the screen and that solved the problem. I have no custom scripts. Your HUD is pretty big though.
 

dale_coop

Moderator
Staff member
Yeah, HUD updating code is quite buggy:
http://nesmakers.com/viewtopic.php?p=5340#p5340

Need to disable some the hud updating code in certain scripts, if you're not using all the hud variables.
 

dale_coop

Moderator
Staff member
Can I ask you why you are checking a max health?
You don't want it to be more than 6?
You need to keep the increment (ADC #$01" before test the value, here), like this:
Code:
	LDA myHealth
	CLC
	ADC #$01
	CMP #$07
	BCS skipGettingHealth

or a check like that should work:
Code:
	LDA myHealth
	CMP #$06
	BEQ skipGettingHealth

And you need to put the playsound before the LDX tempx (this might be your issue):
Code:
	PlaySound #sfx_1up
	LDX tempx

skipGettingHealth:
 
Top Bottom