i am wondering how inventories are made in video games. I have come up with a few different methods but I'm not sure which would work.
My first theory is to have a player have a vector list of item objects as a data member.
My second guess was to make an inventory object then somehow populate it with a derived class of inventoryItems or something like that.
Can someone help me. Or is there another way entirely I'm not seeing?
Or look around in some OpenSource games how they did it.
Although it will probably take a lot more time to understand what they did than implementing some ideas you have. Not to mention that you will be able to learn from your own faults and understand your a lot code better when you do it all yourself.
You pretty much have the idea, an inventory system would just be a list of base class data type. Chances are you would have dozens to hundreds of derived classes since you would have one for each item type. Your base class would have virtual functions for each inventory action such as "Use", "Drop", "Eat" etc. with each item having it's own implementation.