

Let's explore a digital game mechanic...
CRATES

01 Build a Basic Inventory & Shop
Here we will take you through some ways to explore the currency mechanic through building a simple inventory and shop system. Check out our step-by-step guide below!
WHAT WE ARE BUILDING:
A functioning basic inventory and shop system that will allow the player to see their inventory and gold, spend their gold and give the player a way to earn more gold. These are building blocks that are present in most modern games and can be expanded upon endlessly!

- Open GDevelop and click on "Create a Game" from the File menu
- Select "Empty Project" to start a new project from scratch.
- Click on the "Objects" tab on the right and then click "+ Add a new object."
- Choose "Text" from the list of object types.
- Name your text object "InventoryHeader"
- Adjust the text size and font as you see fit.
- Set the Initial Value to "Inventory"
- Add the Gold Display
- Add another text object called "TotalGoldLabel" with the value "Gold:" and size 60
- Add another text object called "TotalGoldText" with the value "00" and size 60
- Drag both onto the scene and line them up together
- Add the inventory item display
- Create 3 new text object called "PotionLabel", "BreadLabel" and "HatLabel" each with the value "Potion:", "Bread:" and "Hat:"
- Create another 3 text object called "NumPotion", "NumBread" and "NumHat" all with the value 0
- Drag all 6 of these text objects onto the screen and line them up next to each other so that the Label is to the left of the Num text object
- Create a new text object called "StoreHeaderLabel" and give it the value "Ye Olde Shoppe" and size 40 and drop it onto the right side of the screen
- Create a new button object and choose a button type that you like
- Name the button "BuyPotionButton" and set the initial text to "Potion - 50g"
- Copy and paste the button twice updating the names to "BuyBreadButton" and "BuyHatButton"
- Update the initial text of the new buttons to "Bread - 25g" and "Hat - 150g"
- Drag the 3 butttons below the "StoreHeaderLabel" on the scene
- Create a new button called "WorkMinesButton" with the intial value "Work the Mines - +50g"
- Drag the button onto the bottom of the scene
- Open up the scene variable
- Add a new number variable called "PlayerGold" and set it to "100"
- Add a new structure variable called "PlayerInventory"
- Add 3 number variable children to the structure called "Potion", Bread" and "Hat" and set them all to 0
- Add a new event with the condition "At the beginning of the scene"
- Set the action to change the text of "TotalGoldText" to the variable value of "PlayerGold"
- Add a new event for when you click the work the mines button
- Add a condition for when the "WorkMinesButton" is clicked
- Add an action to update the "PlayerGold" variable and add 50 to the value
- Update the "TotalGoldText" object with the new variable value
- Add 3 new events for the buy item buttons are clicked in the shop
- Decrease the "PlayerGold" by the purchase amount
- Add 1 to "PlayerInventory.YYY" where YYY is the item we are buying
- Update the "TotalGoldText" to reflect your new total
- Update the "NumPotion", "NumHat" or "NumBread" value to reflect the new number in inventory
- Click on the play icon to preview the scene.
- Try buying items and working the mines to see how it works!
- How can we handle the case where we don't have enough gold?
- Disable the button?
- Display an error message?
- Can we save the progress between game loads?
- What happens to the interface when we aquire a lot of gold?
- Do we need a max gold?
- Make the font smaller?
- Could we simplify things and put the PlayerGold into the PlayerInventory Variable?
- Try dragging PlayerGold into PlayerInvetory
- Don't forget to update the refernces to PlayerGold in the Events!
02 Expanding on it
Check out some additional ways we can use conceptualize currrencies in a gaming context.

- Move the StoreItems into a Global Varaible
- Open the Global variables and add a new structure that contains all the items in the store
- Add in the name and cost of each item so you can reference them in the events later
- Now go back into your events and use your new StoreItems global variable to populate all your store and inventory logic
- Make your button text read from the StoreItems
- On Load have your store buttons update their text to reflect what is in the StoreItems variable
- What about using different things as a currency?
- Houses cost "wood" and "nails" and walls cost "stone"
- How can you aquire different currencies in interesting ways?
- Chop "wood" from trees
- Mine "stone" from a quarry
- Craft "nails" at a forge
- What about different demoninations?
- Silver vs Gold vs Gems?
- How do you "exchange" them amongst each other?
- What about creating variable exchange rates?
- What are some interesting currencies in your favorite games?
03 Your Turn
How will you use currency in your game? How does currency work in your favorite games? How might an inventory or a bank be incorporated into your game?

Get inspired
Check out these games to modify or recreate to explore more ways to use RNG in games:
Build an experience
Use these a template to kickstart your game...add elements and try manipulating RNG to introduce luck into your game.
Share with us
Connect with our social pages to share your designs!