Problems with adding a Lives counter to the HUD

Bucket Mouse

Active member
myLives is the name of the variable, and it's already in the game, coded and everything. All I should have to do is set up that variable in the HUD, which I have done. But the number of lives did not tick down.

I dug into the code and, weirdly, though the content of playerloselife.asm is present elsewhere, it's not included in the ASM that gets loaded into the ROM. Instead, there's an alternate script that simply says "JMP RESET."
So I copy-pasted playerloselife.asm into that script. Now the HUD registers a lost life, but everything else is broken: the player sprite does not appear and 3/4 of the monsters don't move. I have no idea where to go from there. Below is the ASM for playerloselife; do you see anything curious?

Also, I'd like to add a level counter that tells you what level you're on (this is a single screen game with one level per screen). How do I set that up?

Code:
;;; do loss of life stuff here
	DEC myLives
	LDA myLives
	BNE gameNotOver
	;;do gameover stuff here.  Warp to screen?  Show animation?  Just restart?
	JMP RESET
	
gameNotOver:

;;;;;
;;; do warp to continue screen stuff here.
LDA #$00
STA newGameState
 LDA continueMap
 clc
 ADC #$01
 STA temp
 GoToScreen continueScreen, temp, #$04
 LDA #$00
 STA playerToSpawn
; LDX player1_object
; DeactivateCurrentObject
 LDA #$01
 STA loadObjectFlag
 
LDA continuePositionX
STA newX
LDA continuePositionY
STA newY
 

dale_coop

Moderator
Staff member
You could this one instead:

Code:
;;; do loss of life stuff here
	DEC myLives
	LDA myLives
	BNE gameNotOver
	;;do gameover stuff here.  Warp to screen? Show animation?  Just restart?
	JMP RESET
	
gameNotOver:
	;;;;;
	;;; do warp to continue screen stuff here.
	LDA #$00
	STA newGameState
	LDA continueMap
	CLC
	ADC #$01
	STA temp
	GoToScreen continueScreen, temp, #$04	
	LDA #$00
	STA playerToSpawn
	;LDX player1_object
	;DeactivateCurrentObject	
	LDA #$01
	STA loadObjectFlag
	
	; JSR DeactivateAllObjects
 
	LDA continuePositionX
	STA newX
	LDA continuePositionY
	STA newY	

	;; player1 reset health:
	LDA #$03		;;  <--- HERE reset with your Health value
	STA myHealth
 

Bucket Mouse

Active member
That didn't solve the problem completely. I should have mentioned the score gets bugged out after losing a life.

Scenario A: If the player doesn't score before they lose a life, they don't appear on the next life and the monsters don't move.

Scenario B: If the player does score before losing a life, the score is bugged out, and then if they make an action that raises the score, the screen freezes. If they do not score, see Scenario A.
 

Bucket Mouse

Active member
I'm actually using the Maze module, and the points are being generated by running into the enemies when a power-up makes them vulnerable....

That's not where I want to go with this, though, and I plan to modify the game to use the Melee weapon to shoot at them.
 

dale_coop

Moderator
Staff member
There are issues with some hud elements. Try moving the myLives variable to a different UserVar_x (to do that, in hud user variables, rename myLives in something else, and rename an unused one as myLives) and it again in the “hud elements”.
 

Bucket Mouse

Active member
dale_coop said:
And uncomment the line
Code:
  JSR DeactivateAllObjects
in the PlayerLoseLife.asm script.

MyLivesworks now! But....the score is still messed up.

If I lose a life, when the screen reloads there is a blank gap between the Tens and Ones place in the Score. So if I score ten points, the score changes from 1 3 to 2 3, instead of changing from 13 to 23.
 

dale_coop

Moderator
Staff member
Bucket Mouse said:
If I lose a life, when the screen reloads there is a blank gap between the Tens and Ones place in the Score. So if I score ten points, the score changes from 1 3 to 2 3, instead of changing from 13 to 23.

For that, you need to change the HUD element to use. Don't use the "Element 3" for myScore.
To do that, go to HUD & Boxes, in the "User Variables" tab, rename the 3rd element (currently myScore) as "UserVar_2". Then select an unused one, for example, "UserVar_7", and rename it as myScore.
Now in the "Hud Elements" tab, set your element 3 max Value to "0" and "none" for type. Select the element 7 (your new score element) and set it as "number" with your max value.

And test again ;)


PS: need to do all that, because I found out there are some issues with the drawing of the first HUD elements...
 
Top Bottom