Jump to content
  • Advertisement
Sign in to follow this  
void0

Need help with my design

This topic is 4808 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

First of all, if this is posted in the wrong forum, I apologize. Well, I'm struggling with my current design... I have a class Engine which has a StateManager. The StateManager stores game states (IState*) and have basic functionality like push/pop/etc. Now, my game states inherits from IState and is independent from the Engine/StateManager. The problem is that the game states need access to these two. Right now I have a global instance of the engine which is used by the game states. I had the engine a singleton before but I scratched that. Another idea I have is to pass the engine instance to the states when the engine is initialized, thus getting rid of the global access. Any suggestions welcome.

Share this post


Link to post
Share on other sites
Advertisement
I am generally of the opinion that passing in these things through the constructor is evil, in the sense that it clutters things... Especially if you decide that there's something else you want to pass in, and all of a sudden, you have to change ALL of your IState's. I'd say it's best to have Engine be a singleton, and have it set itself up somewhere common (e.g. IState constructor or initialization code in the base class).

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!