Jump to content
  • Advertisement
Sign in to follow this  
sipickles

engine structuring

This topic is 4681 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, My game engine is getting to the point where I have a whole load of classes, which are beginning to need to mesh in more complex ways.... I understand about wrapping one object in another, eg, I have a cGame class which contains a cTerrain class, which contains many cSectors. However, I am struggling when it comes to communicating from one object to another, when they are not in a parent/child relationship like this. Take my class heirachy above. Now add a cListManager class to the cGame object. This contains many cLists, like cLocalObjects (a list of objects active in players cSector). How do I get cLocalObjects list to be able to communicate with the cSectors that are part of the cTerrain? At present they are in parallel branches of my class heirachy. Do i have to route everything through my cGame as a hub? seems like an inefficient away to do it! Excuse my naiveity! Hmmm ANy advice much appreciated. Thanks Simon

Share this post


Link to post
Share on other sites
Advertisement
Don't forget about passing things as references in member function parameters!

Without knowing more about your overall structure I can't say much for sure but to render some possibilites: You could have cGame request a/the cSector(s) from cTerrain and pass it to cLocalObjects as a parameter. Or have cGame pass cTerrain to cLocalObjects and have that request the cSector(s) directly if it makes more sense to do so.

Also in some cases it might make sense for an object to store a reference to another in order to interact (e.g. a resource that knows which manager it came from)

One thing I can say is keep away from the friend keyword, it has it use - obviously - as does everything but it is often used incorrectly to 'fix' problems caused by a bad design in the first place.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!