Best way to do this?

I'm making a fantasy RPG game - There are a bunch of shops you can go into and purchase certain supplies. Once bought, it gets placed into your inventory, which you can access at any time. My question is how should I go about making this invetory where you can store your supplies? What is the best way? I was thinking arrays - is this fine? Would I have to use dynamic memory?

You have to be able to access the inventory at any time during the game. It's got to be able to me modified during the game obviously, as well.

ideas?

Thanks,
Timmah m/
closed account (S6k9GNh0)
Is this a console (as in command prompt) game?
Don't try to think of less important implementation details before the resolution necessitates itself. Just keep them in mind, but don't put them on the front line. Start with anything. More importantly, keep the rest of your code relatively independent so that you can pick different structure later. This is where the art is. By the time you connect the pieces together, your idea will grow with new set of requirements. Who knows what you may end up using - list, map, multi-indexing, intrusive containers, priority queues, the whole shebang. For now, use array if you can afford static allocation, because it is easier to debug. But don't manage dynamic memory manually. Use vector if you ever decide to use unconstrained dynamically sized array.

Regards
Last edited on
Thanks simeonz - interesting response

And yes, it is in command prompt
closed account (S6k9GNh0)
timmah1493, we don't know the perfect way for everything. Only experience can tell us whether something will work well or not. In this case, try out an idea and if you don't like it or think it can be improved, try again. Doing this repetitively will give you plenty of experience.
Topic archived. No new replies allowed.