[4.5] Health Pickup with Sound

offparkway

Active member
Trying to create a health pickup. I made the object and identified it as a pickup/powerup. it shows up in-game, and I can pick it up (but it doesn't do anything yet).

So I went into the pickup script, and copied the code for the myAmmo pickup. I followed the same code, and have it comparing to item 05 (my health pickup) and made it set myLives to 3. I also added the code to play a sound (which works already for myAmmo, but not this time for myLives).

All looks correct to me (I'm not a coder), but I'm getting 3 compiler errors from doHandleObjectCollisions_nonLethal.asm saying "branch out of range", on lines 254, 261,and 263

Here's my code:

CMP #$05
BNE +notThisPickup
PlaySound #sfx_woot
LDA #$03
STA myLives
UpdateHudElement #$03
JMP +endPickups

+notThisPickup:
 

dale_coop

Moderator
Staff member
05 is the "charge pickup" object... are you sure it's he one you want?
Not the "04"?

Reminder (Player is "00"... then, 01, 02, ...)
 

offparkway

Active member
Yes, I have it in the 05 slot. It was the charge pickup item, but I used that slot for a health pickup, and my key item is in 04. I thought they were just labels and didn't matter what went where? Is that why I'm getting those errors?
 

dale_coop

Moderator
Staff member
Yes, just labels, ... but if you write it's #05 and "Health Pickup" object... how do WE know that you already changed the names and you are not using the wrong object, right, we don't see (are not aware of) your project modifications.

If you want to make it easy for us, share screenshots of the settings and share your modified scripts.
Because, right now, everything seems correct.
(but who know... what is the line before your CMP #$05 for ex...)
 

offparkway

Active member
I understand. Ok let's see if this helps... here's a screen shot of my left NESmaker bar (you can see my health item in slot 05) and the modified script I'm trying to run. Object details for the health pickup are the same as the Ammo pickup. The only thing I changed was the script, trying to update HUD element 03 when the heart is touched.

I'm getting those compiler errors with the script as it is right now.
 

Attachments

  • Capture.PNG
    Capture.PNG
    205.2 KB · Views: 9

offparkway

Active member
I understand. Ok let's see if this helps...

In this screenshot, you see my NESmaker sidebar with myhealth pickup object (a heart) in the 05 slot. It's object settings are the same as the Ammo Pickup. The only thing I've changed is the pickup script to the right, trying to get that 05 object to update the HUD at the 03 position (and make a sound).

Everything was working until I added the new section of the script for the health pickup item, and now I get those compiler errors I mentioned.
 

Attachments

  • Capture.PNG
    Capture.PNG
    209.7 KB · Views: 529

dale_coop

Moderator
Staff member
Thx.
I tested your script, it works for me.

So, if your issue is the export & test error, line 254 of the "doHandleObjectCollisions_nonLethal.asm" script, replace the:
Code:
		BEQ notPickupPowerup
by:
Code:
		BNE +pickupPowerup
			JMP notPickupPowerup
		+pickupPowerup:

If you have another issue... tell me more.
( if no export & test error, and your pickup do not update your life HUD, could you share a screenshot of your myLives Hud element settings)
 

offparkway

Active member
Thanks. Ok I replaced what you recommended, and it removed one of the errors. But I'm still getting "out of range" errors on line 263 and 265 in the nonLethal script.
 

dale_coop

Moderator
Staff member
Same kind of modification... check the line and invert the condition...
For example, if the line is a:
Code:
	BEQ notPickupPowerup
You just replace by:
Code:
	BNE +
	JMP notPickupPowerup
	+


If the line is a:
Code:
	BNE anyThing
Replace it by:
Code:
	BEQ +
	JMP anyThing
	+

etc...
 

dale_coop

Moderator
Staff member
No problem, don't hesitate to ask when you have errors... with the message exact (share screenshots) and your modified scripts.
We are here to help each others in that exact kind of situation.
 
Top Bottom