61
General discussions / Design flaw in my game ?
« on: August 16, 2011, 04:28:10 pm »Quote
So, polymorphism is not the best way to write such a state manager, is it ?
I think it's a fine way to do it. It's how I do it myself.
IMO, The problem is you're trying to build something that has nothing to do with states into your states.
I think you're making this more complicated than it needs to be. I would just do this:
Code: [Select]
struct GameEnvironment
{
// .. various "game wide" data that can be used in every state
// throw the Save function in here
void Save();
};
Create one instance of that class in main and pass a pointer to it to each game state when they're created.