1 #include <Flow/GameStateGame.hpp> 2 #include <Flow/StateManager.hpp> 3 #include <Misc/Utils.hpp> 4 #include <Interface/Dialog.hpp> 5 #include <Interface/Ncurses.hpp> 6 #include <Config/Globals.hpp> 7 #include <Game/BoardParser.hpp> 9 GameStateGame::GameStateGame():
13 GameStateGame::~GameStateGame()
20 this->game =
new Game();
21 this->game->start(Globals::Game::current_level);
22 this->game->scores->load();
26 Dialog::show(
"Couldn't load the level! (Error: \"" + e.message +
"\")",
true);
27 this->willQuit =
true;
35 catch (std::runtime_error& e)
43 SAFE_DELETE(this->game);
50 return GameState::QUIT;
52 this->game->handleInput();
55 if (this->game->isOver())
61 this->game->scores->save();
69 return GameState::MAIN_MENU;
72 if (this->game->willQuit())
73 this->willQuit =
true;
75 if (this->game->willReturnToMenu())
76 return GameState::MAIN_MENU;
78 return GameState::CONTINUE;
void draw()
Shows everything onscreen;.
Custom exception class to specify an error that occurred during a level loading.
GameState::StateCode update()
Updates all possible things on the game.
Custom exception class to specify an error that occurred during a level loading.
virtual void load(int stack=0)=0
Where every state initializes it's resources.
void delay_ms(int delay)
Sleeps for #delay miliseconds.
bool askBool(std::string question, std::string title="", bool default_value=false)
Spawns a Dialog box asking for a yes-or-no #question.
void show(std::string message, bool pressAnyKey=false)
Shows a message on the screen.
StateCode
All possible transitions between states.
void load(int stack=0)
Constructs everything necessary for the game.
int unload()
Destroys anything builded during the game.