1#include <Display/Layouts/LayoutGame.hpp>
2#include <Engine/EngineGlobals.hpp>
3#include <Engine/Helpers/Utils.hpp>
5LayoutGame::LayoutGame(
Game* game,
int width,
int height):
17LayoutGame::~LayoutGame()
21void LayoutGame::windowsInit()
23 Layout::windowsInit();
24 this->main->setTitle(
"nsnake " VERSION);
27 this->main->setTitle(
"Arcade Mode", Window::TOP_RIGHT);
29 this->main->setTitle(
"Level " + this->game->board->
getMetadata(
"name"), Window::TOP_RIGHT);
32 this->gamewin =
new Window(this->main,
33 WINDOW_FILL, WINDOW_FILL,
34 WINDOW_FILL, this->main->getH() - 3);
36 this->gamewin->borders(Window::BORDER_NONE);
38 this->info =
new Window(this->main,
39 WINDOW_FILL, this->main->getH() - 2,
42 this->info->borders(Window::BORDER_NONE);
45 this->
pause =
new Window(this->main,
46 this->main->getW() / 4,
47 this->main->getH() / 2 - 1,
48 this->main->getW() / 2,
51 this->
pause->setTitle(
"Paused");
54 this->
help =
new Window(this->main,
55 this->main->getW() / 4,
56 this->main->getH() / 4,
57 this->main->getW() / 2,
58 this->main->getH() / 2);
60 this->
help->setTitle(
"Help");
64void LayoutGame::windowsExit()
66 SAFE_DELETE(this->gamewin);
67 SAFE_DELETE(this->info);
68 SAFE_DELETE(this->
pause);
69 SAFE_DELETE(this->
help);
70 SAFE_DELETE(this->boardwin);
71 SAFE_DELETE(this->helpWindows);
74 this->main->refresh();
76 Layout::windowsExit();
78void LayoutGame::draw(Menu* menu)
87 int x = this->gamewin->getW()/2 - this->game->board->getW()/2;
88 int y = this->gamewin->getH()/2 - this->game->board->getH()/2;
89 int w = this->game->board->getW();
90 int h = this->game->board->getH();
92 boardwin =
new Window(this->gamewin, x, y, w, h);
99 if (this->game->
isPaused && this->game->showPauseMenu)
101 this->
pause->clear();
102 menu->draw(this->
pause);
103 this->
pause->refresh();
111 this->helpWindows->
run();
122 this->info->print(
"a", 0, 0);
124 ColorPair hilite = EngineGlobals::Theme::hilite_text;
126 this->info->print(
"Hi-Score", 0, 0, hilite);
127 this->info->print(
"Score", this->info->getW()/3, 0, hilite);
128 this->info->print(
"Speed", this->info->getW()/3 * 2, 0, hilite);
134 this->info->print(points, 9, 0, EngineGlobals::Theme::text);
138 this->info->print(points,
139 this->info->getW()/3 + 6,
141 EngineGlobals::Theme::text);
144 this->info->print(speed,
145 this->info->getW()/3 * 2 + 6,
147 EngineGlobals::Theme::text);
177 this->gamewin->clear();
179 this->game->board->draw(boardwin);
180 this->game->player->draw(boardwin);
181 this->game->fruits->draw(boardwin);
183 this->gamewin->refresh();
184 this->info->refresh();
185 this->main->refresh();
std::string getMetadata(std::string name)
Gets a meta information from this level.
ScoreEntry * currentScore
Current score for this level.
bool isPaused
If the game is paused.
bool showHelp
If it's showing the help screen.
ScoreFile * scores
All the current level's score.
Window * help
Contains the help screen.
Window * pause
Contains the pause menu.
ScoreEntry * highScore
Maximum high score obtained for the current game.
Specific Window that shows Help and other info during Game.
void run()
Updates and draws all tabs.
std::string level
On which level the user made this score.
unsigned int speed
Under which game speed the score was made.
unsigned int points
How many points the user got.