Building an RPG-Style Inventory

23

Index

Attached Files

The following files have been attached to this tutorial:

.c3p

inventory-system.c3p

Download now 344.98 KB

Stats

13,969 visits, 37,768 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 16 Jul, 2020. Last updated 30 Jul, 2020
.C3P

inventory-system.c3p

Download now 344.98 KB

Welcome to this tutorial covering how to make a robust inventory system. In any game which uses items, you'll usually need some way for the player to view and use their items – hence the inventory.

Different games tackle this in different ways, which means there are plenty of ways to build an inventory depending on your needs. There are also several other examples on this site, so if this doesn't do what you need, be sure to check those out.

The main inspiration for this style of inventory comes from Nintendo's The Legend of Zelda: Breath of the Wild. In this project, the inventory is split into several different categories (stored in arrays) to allow the player to store different kinds of items. When the player is highlighting a particular item, its details are displayed using information stored in a JSON file. The inventory can be sorted and allows items to be added and dropped as necessary. It is all controlled via the keyboard.

  • 9 Comments

  • Order by
Want to leave a comment? Login or Register an account!
  • Thank you! Love it when tutorials pop up for exactly the features I've been thinking about...

  • Hi Laura! I'm struggling to understand where the images for the items are being pulled in from. I don't see it mentioned in the tutorial. Could you please explain? Thanks!

      • [-] [+]
      • 1
      • Laura_D's avatar
      • Laura_D
      • Construct Team Community Manager
      • 1 points
      • (1 child)

      So, both the ItemShowcase and the ItemSlot objects have animation frames for each item. Then, in the JSON file, each item has an ID and these ID numbers dictate the order that the frames are stored in on the Showcase and Slot sprites.

      The Slot images are set from these ID numbers in the Inventory Category Settings event group, and the Showcase images are set during the UpdateInv function.

      Does that help?

  • Thanks for the tutorial Laura! Just a question, is there any reason you specify the items on a JSON file?

    Feels to me that it would be easier to manage if they were created individually under a folder or family since we load the json to memory anyway, unless there is a performance gain I'm missing.

      • [-] [+]
      • 2
      • Laura_D's avatar
      • Laura_D
      • Construct Team Community Manager
      • 2 points
      • (0 children)

      I've not done any testing in terms of performance, but for me, it was down to preference. I didn't want to have loads of different objects even if they were nicely sat in a folder! I assume it would still work using a different object for each item, but I've not tried it!

  • we know that CategoryName is an instance variable of the array(inventory) but where did ArrayName come from?

    edit:o, i just now know it, we can add a thing called parameter in the function.

  • i hope the no. of events is not greater than 50 cause i havent bought construct yet. maybe i can cut down some events for strings.

  • Load more comments (1 replies)