O'Reilly logo

Mastering SFML Game Development by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Application states

Another important aspect of a more complex application is keeping track of and managing its states. Whether the player is in the thick of the game, or simply browsing through the main menu, we want it to be handled seamlessly, and more importantly, be self-contained. We can start this by first defining different types of states we'll be dealing with:

enum class StateType { Intro = 1, MainMenu, Game, Loading }; 

For seamless integration, we want each state to behave in a predictable manner. This means that a state has to adhere to an interface we provide:

class BaseState{ friend class StateManager; public: BaseState(StateManager* l_stateManager) :m_stateMgr(l_stateManager), m_transparent(false), m_transcendent(false){} virtual ~BaseState(){} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required