Adventure Based: Simple script to pick up item and store it in HUD


Good morning NESMakers!

I have been playing around with scripts, attempting to teach myself the ASM 6502 language. My goal at this point, is to have an object that will be placed on screen as a game object with a special tile setting.
Special Item will be a Heart
It will be solid
It should be picked up with the A button and held over head (animation)
Once it has been picked up it will show in the HUD as being obtained (there will eventually be several other special Items to collect)
Eventually, after picking up all special items a secret passage will open.

What I have done so far:
Created game object (Heart) in position 0f
I have created user variable specialItem1 and set initial value to 0
I have created my HUD elements:
- Element 0 (Text: Special Items:)
- Element 1 (Var Tiles, specialItem1, Max Value 1)
I have added a tile type to 9 called special item and started editing the script (see below)

;;This script will pick up GameOgject and add it to HUD Element
;;Example: There are 5 random objects found on the map, as you find each element the character will walk up to it (push button) and pick up item (holding over head) adding it to 1 of 5 boxes in the HUD element
;;After all 5 elements have been found, a secret passage will open (I am thinking this will act like the monster block tile)

;; Step 1 Set object to solid  -- WORKING!!!!
;; this block will become walkable after all monsters in a room are destroyed.

	LDA ObjectUpdateByte
	ORA #%00000001								
	STA ObjectUpdateByte ;; makes solid

;;Step 2 Set variable type SpecialItem1 to 0 with pickup type is gameobject 0f

	LDA Object_type,x
	CMP #$0f  ;;What object is your pickup?  00 - 0f (Our gameobject is 0f)
	BNE +notThisPickup
		;;;;;;;;;;;;;;;;;;;;;;;;; What do you want to do to the value? (add 1 to HUD box)
		;;;;;;;;;;;;;;;;;;;;;;;;; Increase?  Decrease?  Set it to a number?  (Increase)
		;;;;;;;;;;;;;;;;;;;;;;;;; Here, we are setting SpecialItem1 to 0.
		LDA #$00
		STA specialItem1
		;;;;;;;;;;;;;;;;;;;;;;;;; Do we need to update the HUD to reflect this?  (Yes0
		;;;;;;;;;;;;;;;;;;;;;;;;; If so, which element is the above variable represented in? (We will use 1 for this one, 0 will be a text box)
		UpdateHudElement #$01
		JMP +endPickups


What I need to happen now...
I need to pick up the special item with button input with animation holding over head. The above script has set the tile set to solid (which is working) but now I want to pick it up and when I do it adds it to the HUD.
Would I continue to edit the tile script or would it be in another script? Also do I need to create another (new) input script to pick up the item (I ask because I do not see any "pick up item" inputs already built, but I may be over looking this.

Thank you for your help and time!


Digging deeper, I think all I need in the tile 09 script is the code to make it solid. The rest of the code will be in the Game\PickUp Script - routines\BASE_4_5\Game\MOD_Adventure_Base\Game\templatePickUpScript_AdventureBase.asm In this script I can set my game object 0F to 0 and if it is obtained add it by 1 to the HUD element 01.

Now... on to figure out the input script....


Okay... so what I am thinking...

Create new subroutine (maybe call it PickUp Script_Custom) and define it as SCR_PICKUP_SCRIPTS_CUSTOM
- copy and past all contents of PickUp Script into new script

Make backup copy of original Pickup Script then add new subroutine to PickUp Script

Next, find all the locations that the original script is called (SCR_PICKUP_SCRIPTS) and make copies (as to not edit the originals)
- Bank18_Adventure.asm or Bank18.asm (Not sure if one or both)
- doHandleObjectCollisions_AdventureBase.asm or doHandleObjectCollisions.asm (Not sure if one or both)

Now, we are ready to edit our script

but with what... stay tuned!
You are on the right track. You'll need to modify your pickup script, unless you impliment everything into the tile. The tile can be solid until the player presses A and then allow for pickup. In that tile you would INC (increment) your object or it could be done in the pickup script. If you are planning on adding a lot of items you will need to look into the sprite hud too. As far as holding the object over your head, in you tile once the player picks up the object you can change your state to one of him holding the item and then on end animation go back to standing. If you are going to do this with a lot of items, I am not completely sure on this but maybe you would need to do something like how you draw your melee weapon but use a variable to determine what gets shown
Top Bottom