A game design question.
I have a dilemma over a game design problem. I am a beginner in games
development and working on an RPG type game, purely experimental for the
purpose of learning the basics of game development. My implementation is in C++
language.
The problem I am about to discuss is that for instance in a game world, you
have items such as weapons, armour and other stuffs that can be carried by a
player or vendor. My question is should I globally maintain a list of every
item created in the game or should I just create and store these items in their
respective context, such as the player's inventory, the vendor's vector of
item objects, and so on.
I would ask questions like, if I keep such a huge list of all objects created
and destroyed dynamically, would this impact on the efficiency of the game? If
I do not maintain such a list, how am I supposed to know what items were
created and destroyed at any time in a game or how many items are currently
created in game and so on? Without these statistics is it really ok?
If I were to create such a global list, do I use a Factory design pattern
with a vector or list of item objects to keep track of what I have created
or destroyed?
Maybe I got this whole design idea wrong. Can someone help me out?
Thanks.
You could remove the need for freeing the memory by using hans boehm's garbage collector. That would allow you more moving space.
Have you thought about the idea that you do not actually have any global space where to store stuff? Instead, you would have a kind of multi-set, indexed so that searching for items owned by object in your simulation would be dead easy.
so, this set would contain this kind of data domains:
||| void* owner | Item* item ||| plus other information you'd possibly like to store with your items (how are they stored? is the relationship secret? etc.). If you'd possibly use GC, you could just drop items out from map when they dies.
This is could be called relational oriented model. In player class, you possibly know some information (for example if player can only wear one item of kind, you'd have pointer to his armor object there). When player object dies, you just do the logic which handles what happens for his items in the simulation.
You can easily add counter or something to show how many items were created and such, into item constructors.
Just brainstorming from my paradigm twisted mind. :) Try different things and see out how they behaves, then choose one which is best for you.
Have you thought about the idea that you do not actually have any global space where to store stuff? Instead, you would have a kind of multi-set, indexed so that searching for items owned by object in your simulation would be dead easy.
so, this set would contain this kind of data domains:
||| void* owner | Item* item ||| plus other information you'd possibly like to store with your items (how are they stored? is the relationship secret? etc.). If you'd possibly use GC, you could just drop items out from map when they dies.
This is could be called relational oriented model. In player class, you possibly know some information (for example if player can only wear one item of kind, you'd have pointer to his armor object there). When player object dies, you just do the logic which handles what happens for his items in the simulation.
You can easily add counter or something to show how many items were created and such, into item constructors.
Just brainstorming from my paradigm twisted mind. :) Try different things and see out how they behaves, then choose one which is best for you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement