Simple Death Counter

So I used the myScore from the platform tutorial, set up the HUD exactly the way Joe did (except I used the text DEATHS instead of SCORE in the HUD) using the myScore variable. Then I copied the AddValue code that was used to add score when you pick up a carrot or stomp a monster and pasted it into the HandlePlayerDeath scripts like this,

Code:
	TXA
	STA tempx
	TYA 
	STA tempy
	
	;;;;;;;;;;;;;;;;;;;
	LDX player1_object
	LDA Object_x_hi,x
	STA temp
	LDA Object_y_hi,x
	STA temp1
	CreateObject temp, temp1, #$08, #$00
	;; need to do this redundantly, otherwise, the death object will be in same slot as player
	LDA #$00
	SEC
	SBC #$06
	STA Object_v_speed_hi,x
	LDX player1_object
	AddValue #$06, myScore, #$01, #$00
	;;;constant how many places, what variable, how much to change (0-9), what place to change (0=ones, 1=tens, etc etc etc)
	;;;; 
		LDA DrawHudBytes
		ora #HUD_myScore
		STA DrawHudBytes
	DeactivateCurrentObject
	;;;;;;;;;;;;;;;;;;;
	StopSound
	
	LDA #$FF
	STA player1_object
	
	
	LDX tempx
	LDY tempy
RTS
 

Bucket Mouse

Active member
That's cool. Not everyone will use it in the HUD, but it would fit well in the save file screen of an adventure game (those WILL exist eventually).
 
There is one weird thing and I'm not sure what is causing it. Sometimes the HUD updates the second you touch whatever kills you, and sometimes it doesn't look like it updates, but then it does when you respawn.
 

dale_coop

Moderator
Staff member
Yeah HUD is kinda...
Something I noted... each time you hurt a monster, you loose health. In the scripts, there is code to update HUD with the value of myHealh. But if you don't have that information on you HUD (if for exemple you just have Score)... your HUD breaks (he seems frozen, no more updating). Until you change screen.
Same problem when you get a Key, the script update the HUD with the value of myKeys... but you don't have that variable displayed on HUD, it breaks your HUD...
Same for myScore, myMoney....

To fix that, you need to search in all the scripts where the HUD is updated with those variables... and comment if you don't use them on your HUD.
 
Top Bottom