Thank you for visiting Blazing Games

A generic inventory system

The big thing code-wise for this episode was the new ActionScript 3 inventory system. My goal here was to write a flexible inventory system that could be used with other future projects. This was used in the later episodes but really is not as robust as I would have liked it to be. Still, for a basic inventory system it works well enough.

To allow the inventory system to be easily integrated and expanded, interfaces are used as the base classes for the system. For use within the game, basic versions of these classes were created. These simple versions are what the day 6 and 7 episodes use but there is enough flexibility that more complex systems, such as a paper-doll inventory system for a role-playing game, should be possible.

The most important part of an inventory system is the inventory. The IInventoryItem interface really is more of a flexible structure manager than anything. It allows sprites that represent the item and cursor to be set up as well as name, highlighting status, and a generic info object to be retrieved. The object for holding item information makes it easy to integrate this into pretty much any game.

To actually hold the inventory, the IInventoryBox interface is used. This treats an inventory like a container with functions to add, clear, or remove objects to the inventory. Because the inventory system is designed for adventure games, one of the important features is to have the ability to support combining inventory items together. To deal with this, the inventory bar has states to indicate if an item has been selected or if items are being combined. When the state of the inventory bar changes, a INVENTORY_STATE_CHANGED event is generated so that the program using the inventory bar knows what is going on.

There are two ways of using the inventory bar. One way is to simply check the status of the bar when a clickable item is clicked on. The more flexible way is to capture the inventory state change event. This gives you the ability change the cursor when an item is being used and track combining of items.

Previous page
Chapter 37 Page 4

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2009 Blazing Games Inc. All Rights Reserved