Posted by Fobwashed (1899 posts) -

What is this?

I've been working on building a game for quite some time now and have been periodically posting blog updates on my progress. This one is specifically about inventory. The first half is about my thought process and how I decided to use the system I'm using and the second half is about building the actual system into my game.

Inventory In Games

I've spent on and off quite a bit of time determining what type of inventory I wanted to use in my game. This all came to head this last week and half as I began building out the inventory systems in earnest. Here's the thought process I went through to determine what type of system I wanted to build and use.

Infinite Inventory/Pockets

INFINITE SPAAAAAACE!!!
An infinite amount of space limited by weight.

Games that throw any sort of inventory management out the window fall into this category. This system is most prevalent in RPGs and single player games that are loot and equipment driven and more common in games that have you controlling a party of characters. Games that strive for some amount of realism, while still allowing the player to loot usually apply an arbitrary weight limit based on the player's strength punished by encumbrance. I considered it briefly but decided that if I were to make this concession, the game would be drastically different in play than the one I envisioned. This type of inventory is by no means a bad thing and I actually would have it no other way in the majority of games I play but it has a time and a place. Neither of which is my game -_-;;

Slot Inventory

Slot inventory is the type that is found in most multiplayer loot driven games. This includes Diablo type games and most MMORPGs. The basics are that you have a limited number of spots, but each spot is of an infinite size and can hold any size item. While this system does effectively limit the amount of inventory space a player has, I don't like the idea that a large item would take up the same amount of space as a middle sized item. Or more importantly, that small items may take up as much space as a medium/large sized item. You can commonly stack a number of smaller items into a single slot, but the problem is still there in that when the slot has only one small item, it takes up as much space as when the slot holds 10 of the same item. Something about that just rubs me the wrong way. I feel like this type of inventory serves a lot of gameplay purposes but they don't fit what I'm looking for.

Tetris Inventory

This lead me to consider a type of inventory that was made famous (at least in my mind) by the grand daddy of realistic strategy games, X-Com. This is basically a slot system where larger items take up more slots and must be manipulated to fit along with other items that are in your inventory. This system alleviates some of the size discrepancy problems I have with the basic slot inventory system, but it's more of a band-aid than a real fix. In most games that use this style of inventory, items are picked up individually and placed into the single set of slots the player has as inventory. Since placing objects into the environment will play a large role along with various objects having various amounts of space, that would mean that I'd have to set up specifically sized boxes for every container in the game. A bit much for me alone -_-;;

Volume Based Inventory

Excluding these other routes lead me to the system I've decided to use which is a volume based inventory. What this boils down to is that every carry-able item in the game will have a volume as well as a weight and every container a volume capacity. This means that the space taken up by objects will always be the proper amount of space. This would allow for containers themselves to be stored within other containers properly. For instance, if a bag's capacity is 10 and its volume is 2 and it is stuffed with 5 volume worth of items, its volume is now 7 and can fit within another bag that has a volume of 7 or more. The weight of the items being carried would be the total of all items involved. As far as I know, I've never seen this type of system before and am wondering if there's some crazy flaw with it that I just haven't thought of yet. If you can point one out, go ahead and let me know =)

Building the Interface

So, now that I know what I want, I need to build it. The first thing I needed to determine was what type of item display I wanted. The easiest way would be to have a fully text based system where the inventory would be displayed in a text list format. . . but damn that's boring -_-;; Every game I've ever played where I spent any time with inventory in an engaging way had visually represented items and equipment and I think it important that I do the same. Especially in a game where the things you decide to carry (and leave behind) will be critical. So I'm going the way of the most common type of visual inventory which is slot based. I have no need for a tetris like arrangement since the capacity will be controlled by volume and since the space available will not be represented by the number of slots, the number of slots in every container needs to be infinite (or at least, as many as is needed). Now begins the coding and arting to put into play the systems I need.

What goes into an inventory display?

When you dig into actually building a window, you begin to realize that there are a ton of little pieces that make up even the simplest of windows. Apart from working within the engine of my game, I had to separate all the little bits of functionality that I wanted and put it all together from scratch. Here's a list of the initial things I wanted possible with this window.

  • Scaling, virtually infinite number of item slots.
  • Re-sizing of the window.
  • Move the window around the screen.
  • Collapse the window into a smaller footprint while being able to display pertinent info.
  • Scaling of the size of the window to a larger and smaller size.
  • Sorting by name, volume and weight.
  • Scrolling up and down.

And the resulting window.

I accomplished most of my goals but the way the player interacted with the window was troublesome and some of the functionality was hidden from the player.

Take 2

In the second pass, I tried to make it more obvious that the player could collapse the window and change the scale by adding more iconography. Now the player can still double click the title bar to collapse the window, but there is an additional minimize/maximize button where most windows users would expect it to be. Also, collapsing the window could now be accomplished simply by resizing the window to collapse instead of needing to use the button. I also added a Volume percentage to the status bar on bottom along with a weight reading. The volume is shown as a percentage since the volume figures themselves may potentially be pretty large. It's also somewhat transparent now.

Take 3

Now with those features in place, I added the window scroll bar to the right. Whilst building this out, I discovered way more about scroll bars than I thought I'd need and learned some things that are obvious now that I know them. For instance, the bar itself represents the vertical window you are looking at while the length of the track represents the total vertical space that it is possible to view. So that's why when you increase the size of a window, the bar grows with it and visa versa.

Take 4

At this point, it became necessary to build tool tips. Partly to show the functionality of buttons when hovered over but mostly to display information about the items within the inventory.I changed some of the visual styling of the inventory and set it up so that if you hit minimize, it saves the state of the window (rows and columns) prior to the resize to open back up to the same state it was in previously. It's this level of detail you have to get into when building anything because if you don't put it in, the game won't know what to do =P

Beware of Thursday Night Throwdown music on this one -_-;; oops.

Take 5

I added an increase in transparency when the window is not the current focus. Since this video I added a timer to allow a grace period for when the cursor is not on the inventory window before the fading starts. I'm considering having the window keep focus until the player clicks elsewhere but I'll decide on that once the game is up and fully running to see how that'd effect the flow of gameplay. I've also implemented item rearrangement and the scrolling to work when the player is holding an item over either the title or status bars or above/below the scroll bar to allow the player to navigate the inventory window without the use of left click.

Conclusion for now

So this is where I'm currently at. Figured this'd be a good point to take a breather and put together a blog post about it =P I've still got plenty of edits to make including the stacking of small items and some level of color coding in the actual inventory window that may indicate the individual item's state. As always, please feel free to comment and criticize =) I welcome any thoughts on how I can improve things or change things for the better. I'm also open to any sort of discussion on inventory since it's been on the forefront of my mind as of late.