Possible Duplicate:
Android game rpg inventory system
Still stuck on making my rpg in java, there’s one method I don’t know how to implement. Right now, I want to make an inventory checker for the game, like for example it checks how many herbs are in my pack…how many candies I have in my pack and so on.
How can I implement an inventory for my game and how can I show the players what items are in the inventory present?
Is contains method necessary?
I implemented an inventory in my Java game Tyrant many years ago which you might find useful.
Most of the code is in the “Thing” class, which implement an inventory:
https://github.com/mikera/tyrant/blob/master/src/main/java/mikera/engine/Thing.java
Key things to consider: