I have been developing a C++ IF parser and i am now at the point where objects are getting into the game. However , I’m not entirely sure of how to organize them according to types and manage them effectively. I know i should create categories such as containers ,contents and connectors and store states to some booleans ,though this is easier said than done. Using multiple inheritance with classes and structures might be what im searching for but I cant think of any way to implement it right. Can someone provide some generic info on how to properly manage objects or point to some reference ?
Any help would be greatly appreciated.
Inform was originally designed with no classes at all. Inform 7 uses a simple (single-inheritance) model which should be fine for your purposes:
Object is the base class.
Thing is a subclass of Object which represents anything the player can directly manipulate.
Room is a subclass of Object which can contain a list of Things.
Container is a subclass of Thing which can contain a list of Things.
Player is a subclass of Thing which can contain a list of Things.
A Thing has a “parent” (an Object or null), which is the Room/Container/Player that holds it. You have to make sure that a thing has no more than one parent at a time.
Contents and connectors don’t need to be in the model. (A Thing represents stuff which can potentially be contents.)
Once you get all that working, tackle doors.
Thank you very much Zarf.
It’s worth to note that TADS uses multiple inheritance extensively to create rich class hierarchy and albeit TADS’s object and inheritance model is different from C++, so it will not be directly applicable for C++, studying heavily commented adv3 source code is surelly remarkable source of inspiration. If you need something less heavy, Eric’s Adv3lite would be alternative.