I'd like to see something about making and managing inventory systems.
An inventory system's just a dictionary (in Python), essentially. If you wanted to, you could just use an array to represent the inventory of a character, and have the indices represent the ID of the item (i.e. inventory
is for potions, inventory
is for ethers, etc). Dictionaries allow you to access an index by its name, though. So, you could have inventory['potion']
be the inventory slot for potions. You could also put a dictionary in there to represent the name, description, number, etc. of the item (inventory['potion']['number']
is how many potions you have in your inventory).
To represent the dictionary in a GUI is a bit more work. Basically, you create slots, and each slot gets an index. You use that index to reference the inventory item. If the number's greater than 0, then you would change the image of the slot to be the one that corresponds to the item in the slot. You could do this with just if
-checks, or you could assign each item a unique ID number that also represents where the item is on the sprite sheet (i.e. ethers have the ID of 3, and are the 4th sprite in the inventory item icon sprite sheet).
EDIT: It depends on which language you're using exactly how the inventory is managed. Python does give you nice tools to work with dictionaries, though.