Update HUD on pickup? [4.1]

This may have already been discussed, but has anybody figured out how to make the HUD update when you pick up a powerup (like health) as of 4.1?

The health updates instantly when the player is hurt, but you have to move to another screen to make it update from a powerup.
 

dale_coop

Moderator
Staff member
Speaking for myself, I just assigned the "PowerUp_IncreaseHealth" to the Power Up 01 and used this game object.

2019-01-07-20-24-25-Param-tres-du-projet.png


And also added an SFX named "SFX_INCREASE_HEALTH" (in order to compile without error).
It seems to work fine.
 

PhilJeffries

New member
I can get the health to regenerate, but if the character is at full health, they go down to a single point.
I've implemented the code used in this thread, but in the script for Increasing Health it says to run a check for max health.
I have NO clue what that means...

first post by the way, was planning on introducing myself and posting a demo in the next few days.
i just really want to get this part right before i do.
 

dale_coop

Moderator
Staff member
Hey PhilJeffries :)
For the script, it means if you have a PowerUp_IncreaseHealth.asm script assigned to one of your pickup/powerUp game objects and use it in your game, you might need to modify this script.
Currenlty at the beginning of that script, it check if the health less than the max health before increase it (the max value in hard coded in the script). So you may have to adapt that to your health variable name and your max value (if different).
 

PhilJeffries

New member
(I noticed right away that one of the most prominent users here shares my interest with the black lodge! cheers!)
So looking back at the code, I just wasn't sure which Values I should be messing with.
But I think I figured that part out and the HUD/Health is now functioning properly for the most part...

...except for one thing: The very first health pickup (game starts in a kind of 1 room, warp screen) drops your health back down to 1 while at max, BUT all of the other health pickups recognize that max health normally.

thank you yrev very much for the assist!
 

dale_coop

Moderator
Staff member
Ah ah... yrev very happy to meet you too, Agent Jeffries ;)

Not sure what could cause that... First, I will suggest to check your "myHealth" initial value (in "HUD & Boxes > User Variables" select myHealth and check that is "3" and not "1").
 

PhilJeffries

New member
Yeah I'm at a loss for why it's acting like that, but I went ahead and just deleted that first health pickup from the initial screen.
Now it seems like everything is running smoothly!
I had the HUD User Variables all set up as you've suggested, but it was still bugging out over that one thing.
OH well, problem solved! (for now, and hopefully in the long run:))
 

dale_coop

Moderator
Staff member
Sometimes, the HUD doesn’t update corrcmy (for example, when 2 updates at the same time...)
Could be something like that (or maybe your player object initial health is not set to « 3 »?)

NES dev need a lot of compromises, tricks and play tests ;)
 

PhilJeffries

New member
Whoa! I think you nailed it with that bit about the 2 updates error...So I’m a complete and utter novice at programming and was using weird/bad methods to accomplish something like a fake “score” at first.

I was manually changing the collisions of tiles under heart pickups to give a key, then just changed the Keys to “score” (I know I could have just added a proper score, trust me, I’m BAD at coding). The idea was to just have something in the HUD be able to count up. Also the objects wouldn’t disappear, and I hadn’t a set a bounding box.

When I figured out how to make proper pickup objects, I deleted all of them. Except for the starting screen!

I’m sure this is all basic, easy stuff for all you nes-wizards, I’m only posting this in case anyone else goes searching for answers.
 

PhilJeffries

New member
Unless those things aren’t related, and I’m just getting lucky somehow, despite my super limited understanding of how this all works
 

Atarath

Member
dale_coop said:
Sometimes, the HUD doesn’t update corrcmy (for example, when 2 updates at the same time...)
Could be something like that (or maybe your player object initial health is not set to « 3 »?)

NES dev need a lot of compromises, tricks and play tests ;)

I'm going to necro this thread really quick. Is it a known issue that the hud will glitch when it updates two vars at the same time? My game will literally freeze when it happens. Is there any known work around?
 

dale_coop

Moderator
Staff member
A small thing to know... there is a "bug" in NESmaker with myHealh hud and the starting screen.
When you start the game, on the starting screen, your health is not displayed correclty (it's not the myHealth value) in the HUD... instead, it's displayed full, at max.

To fix that issue:
1) modify the "HandleUpdateObjects.asm" script (in the "Basic\System\" folder), around line 193, locate those lines:
Code:
			LDA #HUD_LOAD	
			AND #%01000000
			BEQ +
			STA hudElementTilesToLoad
And modify like this (adding a line of code):
Code:
			LDA #HUD_LOAD	
			AND #%01000000
			BEQ +
			LDA myHealth	;;HERE <-------- fix to start with the correct hud health
			STA hudElementTilesToLoad

1) modify the script assgined to the "Hud Element 0" element in your "Project Settings > Script Settings" (it should be the HUD_Element_Var_Image.asm script), , around line 12, locate those lines:
Code:
DoScreenOffHudUpdate:
	LDX player1_object
	LDA Object_health,x
	STA myHealth
And modify like this :
Code:
DoScreenOffHudUpdate:
	; LDX player1_object 	;; commented out !
	; LDA Object_health,x	;; commented out !
  	; STA myHealth	;; commented out !
	LDA myHealth	;;dale_coop: fix to start with the correct hud health
Now it should display the right health value in the HUD.
 
Top Bottom