Inventory & Objects
BlitzMax Forums/BlitzMax Beginners Area/Inventory & Objects
| ||
I'm just getting my head around this OO stuff and i need a little help. I'm creating an inventory system and just want to know if i'm on the right track. So Far I have World Object Item Object Extends World Object Do i create a bag / Inventory object to put these in or set a field to say the item is in my bag / Inventory? Hope that makes sense. |
| ||
Quite possibly both, but certainly the former. If you only set the field, you're going to have to cycle through every object in the world, checking for that flag when you want to access the inventory, which is not practical. Only you know for sure if your objects need to know if they're in the inventory or not. Maybe or maybe not. |
| ||
I would have container objects that have an array (or list) that stores the items, but I would also have a parent field on every object that is set when that object is placed inside the container, this allows you to get the parent from the object easily. Even if you don't think that you'll need this functionality just now, you quite probably will later, and it's much easier to implement from the start. |