Introducing the state pattern
All of the problems mentioned previously can be avoided after some careful white-boarding and consideration. The possibility was brought up earlier of different game states simply being localized to their own classes. All of these classes will share the same methods for being updated and rendered, which makes inheritance the word of the hour. Let's take a look at our base state header:
class StateManager; class BaseState{ friend class StateManager; public: BaseState(StateManager* l_stateManager) :m_stateMgr(l_stateManager),m_transparent(false), m_transcendent(false){} virtual ~BaseState(){} virtual void OnCreate() = 0; virtual void OnDestroy() = 0; virtual void Activate() = 0; virtual void Deactivate() = 0; virtual void Update(const sf::Time& l_time) = 0; virtual void Draw() = 0; void SetTransparent(const bool& l_transparent){ m_transparent = l_transparent; } bool IsTransparent()const{ return m_transparent; } ...