1#include <Flow/StateManager.hpp>
2#include <Flow/GameStateGame.hpp>
3#include <Flow/GameStateMainMenu.hpp>
4#include <Flow/InputManager.hpp>
5#include <Misc/Utils.hpp>
6#include <Config/Globals.hpp>
14 this->currentState->
load();
16StateManager::~StateManager()
18 if (this->currentState)
19 this->currentState->
unload();
21 SAFE_DELETE(this->currentState);
25 bool letsQuit =
false;
29 InputManager::update();
36 whatToDoNow = this->currentState->
update();
40 case GameState::CONTINUE:
45 this->currentState->
unload();
46 delete this->currentState;
47 this->currentState = NULL;
52 case GameState::GAME_START:
54 this->currentState->
unload();
55 delete this->currentState;
58 this->currentState->
load();
62 case GameState::MAIN_MENU:
64 this->currentState->
unload();
65 delete this->currentState;
68 this->currentState->
load();
76 if (this->currentState)
77 this->currentState->
draw();
79 Utils::Time::delay_ms(100);
This represents the actual game taking place.
StateCode
All possible transitions between states.
virtual int unload()=0
Where every state destroys it's resources.
virtual void draw()=0
Called every frame, where states draw stuff on screen.
virtual StateCode update()=0
Called every frame, where states calculate everything that can change.
virtual void load(int stack=0)=0
Where every state initializes it's resources.
StateManager()
Initializes pretty much everything.
void run()
Main entry point and game loop.