[4.5] Health Pickup with Sound

Post Reply
offparkway
Posts: 40
Joined: Thu Jun 11, 2020 6:30 am

[4.5] Health Pickup with Sound

Post by offparkway » Sat Jun 27, 2020 11:01 pm

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:
User avatar
dale_coop
Posts: 5386
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.5] Health Pickup with Sound

Post by dale_coop » Sun Jun 28, 2020 3:52 pm

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, ...)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
offparkway
Posts: 40
Joined: Thu Jun 11, 2020 6:30 am

Re: [4.5] Health Pickup with Sound

Post by offparkway » Sun Jun 28, 2020 7:58 pm

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?
User avatar
dale_coop
Posts: 5386
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.5] Health Pickup with Sound

Post by dale_coop » Mon Jun 29, 2020 7:27 am

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...)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
offparkway
Posts: 40
Joined: Thu Jun 11, 2020 6:30 am

Re: [4.5] Health Pickup with Sound

Post by offparkway » Mon Jun 29, 2020 8:22 am

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.71 KiB) Viewed 102 times
User avatar
dale_coop
Posts: 5386
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.5] Health Pickup with Sound

Post by dale_coop » Mon Jun 29, 2020 10:00 am

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: Select all

		BEQ notPickupPowerup
by:

Code: Select all

		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)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
offparkway
Posts: 40
Joined: Thu Jun 11, 2020 6:30 am

Re: [4.5] Health Pickup with Sound

Post by offparkway » Mon Jun 29, 2020 8:32 pm

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.
User avatar
dale_coop
Posts: 5386
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.5] Health Pickup with Sound

Post by dale_coop » Tue Jun 30, 2020 10:10 am

Same kind of modification... check the line and invert the condition...
For example, if the line is a:

Code: Select all

	BEQ notPickupPowerup
You just replace by:

Code: Select all

	BNE +
	JMP notPickupPowerup
	+

If the line is a:

Code: Select all

	BNE anyThing
Replace it by:

Code: Select all

	BEQ +
	JMP anyThing
	+
etc...
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
offparkway
Posts: 40
Joined: Thu Jun 11, 2020 6:30 am

Re: [4.5] Health Pickup with Sound

Post by offparkway » Thu Jul 02, 2020 9:00 pm

Thanks Dale! This works great. Sorry... I'm not a coder so I get lost with it sometimes.
User avatar
dale_coop
Posts: 5386
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.5] Health Pickup with Sound

Post by dale_coop » Fri Jul 03, 2020 11:39 am

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.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
Post Reply