Jump to content
  • Advertisement
Sign in to follow this  
dancuc

C++ RPG Inventory

This topic is 3721 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I've read some topics here on gamedev.net regarding to creating inventory in C++. But in any of these was not explained what I need. I need this: An inventory class in which I can declare item name, item description and the effects An Show Inventory class, which will list the inventory, for example: /Inventory: /1) Glock 27 /2) Car Keys /////////// And after pressing a specific number it'll show description of this item. Is this possible? I am compiling it under Linux. Thanks for any help in advance.

Share this post


Link to post
Share on other sites
Advertisement
Yes, it's possible. However, why do you need a Show Inventory class? "Show", being a verb, is more easily represented as a function.

Share this post


Link to post
Share on other sites
Create a class called Item which stores the name and description of an item, along with whatever other stats you might need. Then create an inventory class which holds a list of these items and has functions to print item names and descriptions. Toohrvyk is correct - The inventory class would have a function to display the inventory. Do not make that a class. You might want to review the differences between a class and a function and when exactly classes are useful.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!