Game inventory

Hi =). I was wondering if anybody could point out some smarter techniques for creating a simple RPG game inventory system which the player could access and the game could access through the code say if I needed a certain tool to do something and I needed to check for it how would I do that? Thank you =)
Last edited on
How you do it is dependent on the way you want it to function. The easiest way, though it may not be applicable to your circumstance, is to have separate 'groups' which you can access items from within, which can be split just through data.

For example, you'd have a 'Weapon' list, and an 'Armour' list, and a 'Potion' list, and a 'Tools' list, or whatever you needed. Then, if you needed a tool, you would search the 'Tools' list for the tool, and use the data for that tool there.

If you need more details, or an example, just ask. While you're at it, give us more detail on the kind of system you had in mind.
Ok well the game at the moment is text based but in the future I plan to add graphics in. So the player has to access the inventory through char inputs which I suppose would work but its harder. I want a way they can access at anytime by pushing e or i anywhere in the game. Can normal c++ do keyboard recognition for that? I was thinking for the actual inventory though somewhere along the lines of arrays? Would that still work for having items and amounts of certain items? See I'm looking into it for the soul purpose of having an option to buy and sell things at the market, smith, tailor, ect. And use maybe weapons and armor in a combat situation or the such.
Last edited on
As NT3 alluded, an inventory system can be as simple or as fancy as you want to make it. Do a search here and you should find numerous topics on inventory systems, most of which utilize STL containers to store inventory objects.

As for recognizing "i" or "e" at any point in the game, that is up to how you handle input. You probably want a centralized command handler that recognizes and processes common commands. In a console based game, you normally process keyboard I/O synchronously. i.e. Your main loop prompts the user for a command, calls a command handler for that command, then when the command handler returns, prompts the user for another command.
If you want to get into graphical games, I recommend you just ditch what you have right now and start with that.

Life will be easier (in some ways). The whole starting off video game development by writing little throw away text adventures is a waste, IMO. You really don't learn anything relevant by doing that.
Alright thanks =). And ya eventually when I get a graphics library hooked up I'm gonna move on to graphics I'm just getting in that game creation mode having all the if statements, collisions in the story with a quest line ect. Thanks for the info =)
If you want to get into graphical games, I recommend you just ditch what you have right now and start with that.


This.

You likely won't be able to "drop in" graphics later. The way normal programs work is much different from how the console works. So anything you're doing in the console will likely take serious reworking in order to get it to work with graphics.

You're better off just starting with graphics from day 1. It's not as hard as you might think.

Get SFML:

http://www.sfml-dev.org/
Topic archived. No new replies allowed.