(4.5.9) Creating a Shop Screen with Tiles ("Zelda" type Shop Screen)

NightMusic

Member
Hello! The following is how I create Shops in my games:


1st Follow the following tutorial : https://www.nesmakers.com/index.php?threads/update-multiple-hud-elements-simultaneously-4-5-9.8360/

2nd : Have user screen bytes AND tiles 14 and 15 enabled following this video: https://www.nesmakers.com/index.php?threads/making-userscreenbyte0-7-work-plus-bonus.5842/

3rd : create a HUD element and User variable for myCash

--------------------------------------------------------------------------

Add an NPC Shopkeeper :

I created an npc and used the adventure npc draw text input on press "A" button in main game state

* I added text to instruct to press A to buy items and Up on door to exit. *


--------------------------------------------------------------------------

Shop Tiles!!!
Original Forum Topic :
@tbizzle and @dale_coop (i almost typed Dale_Cool, which wouldn't be a misnomer ;) He's so helpful. Thank you! )

User Variables to add :

AS WITH SCORE , Add one For each place in your variable you desire...

FOR EXAMPLE in my game I have up to 99 cash

so I have :
myCash
myCash_10

If you have 999 as max cash you'd have :
myCash
myCash_10
myCash_100

etc...

In the scripts/code, I check the max place first for things usually:

EXAMPLE :

The cost is 57 but you have 999 max money...

LDA myCash_100 ;; this would check the max place first ;;
CMP #1 ;; or #$01 ;;

etc.


NOW you have variables and have an understanding of checking the screen flag ...


we code our multi-tiles and/or our old tiles I WILL SHOW BOTH :)


WHEN CHECKING INPUTS (* IF YOU WANT TO NULL THEM IN SHOP SCREENS )


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

LDA ScreenFlags00
AND #%00000001 ;; SCREEN FLAG 07 ;;
BNE +isShopScreenFlag
JMP +isNotShop

+isShopScreenFlag

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

SOMEWHERE ELSE NEAR THE BOTTOM OF YOUR SCRIPT ADD :

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

+isNotShop

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

This Screen Flag 7 we will use will be referred to by anything wanting to detect if you're on a shop screen


Example :

If you desire to disable jump or attack in shops you should put this check in your code.
We can use it best for our ammo tile to be used for BOTH a normal get ammo tile AND a cost cash to BUY this ammo tile.
We can use it to tell multi-tiles when we're on a shop screen add a life but cost us 25 cash..
but that same tile on a normal screen will give us 5 cash.


NOTE :

When creating a shop tile you must subtract or add or check generally a value above the one you need.
When checking for example your tens place if the cost is 25 you'd check 3 to see if they have an amount over 25 in the next of the same digit place aka 3 (which would equate to 30+), then check for the value you're searching for.. in this it would be 2.
having found the value above the one you need you'd send that immediately to subtract value part and create object... however... if you find the value equal to the one you need, you must test the place value under that against the next set..
you'd check say myCash_100 then myCash_10 then myCash...
I will include my scripts for reference.


AMMO TILE (And the other script is for your JUMP to be null on shop screens)


SCRIPT : https://drive.google.com/drive/folders/1UArCYxew2dvUj9wBPReyxcErdicjHgrE?usp=sharing


ALSO : WHY WOULD YOU DISABLE JUMP IN A SHOP?
Well I can design my shops to not need jumps, and I plan on having it do :

PURCHASE WITH THE "A" BUTTON PRESS

The code is as follows:


;;;;; OPTIONAL PRESS A TO BUY ;;;;;
;; BELOW is CHECK INPUT A BUTTON ON GAMEPAD FOR PURCHASE ITEM ;;
LDA gamepad
AND #%00000001 ;; check for A button ;;
BNE +canCheck ;; goes to entry for +canCheck OR below is what happens ... ;;
JMP +notPlayer ;; goes to +notPlayer entry ;;
+canCheck
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


with your jump disabled and A button to purchase power ups, you can see why you would want this possibly.


EDIT YOUR WARP TO SCREEN ALSO TO CHECK FOR UP BUTTON PRESS
(If you need help with this i can include that script as well)

EXAMPLE :

Code:
;; BELOW is CHECK INPUT A BUTTON ON GAMEPAD FOR WARP ON TILE ;;

+checkAInput

    LDA gamepad

    AND #%00000001     ;; check for A button         ;;

    BNE +canWarp    ;; goes to entry for +canWarp OR below is what happens ... ;;

        JMP +notPlayerForWarpTile    ;; goes to notPlayerForWarpTile entry ;;

+canWarp


;; BELOW IS MACRO FOR WARP ;;  

    WarpToScreen warpToMap, warpToScreen, #$01

        ;; arg0 = warp to map.  0= map1.  1= map2.

        ;; arg1 = screen to warp to.

        ;; arg2 = screen transition type - most likely use 1 here.

            ;; 1 = warp, where it observes the warp in position for the player.

+canWarpNormal
 
Last edited:

NightMusic

Member

(4.5.9) Creating a Shop Screen with Tiles ("Zelda" type Shop Screen)​

(Part 2)


View: https://youtu.be/sv-AOMdqveo



EDIT YOUR WARP TO SCREEN ALSO TO CHECK FOR UP BUTTON PRESS


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Multi-Tiles Used for purchasing and for cash drop.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
Last edited:
Top Bottom