Inventory System - Design & Theory


I want to talk about Inventory System Design, and get some ideas or feedback on ways to approach and improve the design. Inventory systems are used in many games, and can be a challenging thing to build for many. I'm not overly worried about the exact syntax and code needed to build an inventory, as much as ideas for how it should be designed and work.

To offer a bit of information to help paint the picture - I am currently developing a traditional Rogue-like / Dungeon Crawler game called Darkest Depths. The game is played from a nearly top-down but more 3/4th's perspective. The bulk of the game is played inside of a large tower with procedurally generated floors, although the player can exit the tower and return to a nearby village where they can sell and buy items.

I've designed (more or less successfully) inventory systems before but want to write out my ideas here and hopefully have them picked apart if needed.

- The inventory system will consist of a number of slots or buttons on the screen that a player can click.
- Inventory slots stack Items (You can have 33x Potions on one slot)
- Inventory slots maybe able to split stacks. (I prefer all items in one slot, less complex)
- Clicking an inventory slot will show information about the current item and present a few options.
- Items can be Equipped: Swords equip to a Weapon slot, Armor equips to an Armor Slot, Rings to an Accessory slot.
- Items can be used: Potions can be used directly, food can be eaten, etc from the inventory slot.
- Items can be dropped: Drops items to the ground below player (Items have to be clicked to pick up)
- Items can be moved around the inventory (Drag slots around)
- Items can be set to a Quick Slot (At this point Usuable items can be used from a single click in game, outside of menu)

These are just a few ways that the inventory will work. There are other features to consider such as giving each items weight, how to handle Shops (buying/selling), how to handle Chests and other 'storage' containers.

Not so much of a question - but I am wondering how you guys have designed simple or very complex Inventory systems in your games, and if you have any ideas that would improve mine before I dive to deep into it. Code is always welcome, but I am more interested in how these systems can work best rather then the exact syntax needed to develop them.

In addition to the above, I started thinking about the actual methods that are needed to build an inventory system, below are some ideas on how different methods of using the inventory could theoretically work.

//Item Pickup Script
- If item quantity > 0 just increment and quit.
- If item quantity = 0 check if inventory is full, if so quit.
- If inventory isn't full, find first open slot and set it's hold id to item id, increment item quantity, destroy item, then quit.

//Item Drop
- If item quantity > 1, decrement item quantity, create item on ground.
- If item quantity = 1, decrement item quantity, create item on ground, empty slot.

//Item Equip
- Set equipped slot (weapon,armor,acc.) to item id, adjust active attributes.

//Item Use
- Decrement item, empty slot if = 0, activate item effects.
Last edited:

Jacob T Wharton

I have tried using a 2d array to represent the inventory and to store information about each item.

For instance,

Inventory[0,0] = "sword"
Inventory[0,1] = 4 //weapon damage
Inventory[0,2] = 12 //item cost

Inventory[1,0] = "magic ring"
Inventory[1,1] = 1 //item effect script index
Inventory[1,2] = 250 //item cost

This is just the basic idea of what I tried before. It seemed to work ok.


That's exactly how I am currently storing my inventory data. It seems to work pretty good, I'm sure there might be more efficient ways but it gets the job done. There are different ways to handle inventories of course, always interested in how other game developers design theirs!
A more flexible method is to store item information in a separate data grid. Then, rather than set all of the stats for the item slots as it is moved around, just reference the item_id from the data grid.