-
Notifications
You must be signed in to change notification settings - Fork 0
/
endview.cpp
41 lines (33 loc) · 1.15 KB
/
endview.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "endview.hpp"
#include "gamemodel.hpp"
#include "menuview.hpp"
EndView::EndView(GameModel *model)
: stf::smv::IView(model) { }
void EndView::show(stf::Renderer &renderer)
{
GameModel *GM = static_cast<GameModel*>(m_model);
const int hw = renderer.Size.x >> 1;
const int hh = renderer.Size.y >> 1;
if(GM->points() == GM->TotalBombs)
renderer.draw({hw - 8, hh-2}, "CONGRATULATIONS!");
else
renderer.draw({hw - 5, hh-2}, "GAME OVER");
renderer.draw({hw - 5, hh}, "Points: %d", GM->points());
renderer.draw({hw - 5, hh+1}, "Lifes: %d", GM->lifes());
renderer.draw({hw - 10, hh+2}, "Game time: %d:%d:%d:%d",
daysFromSeconds(GM->gameTime()),
hoursFromSeconds(GM->gameTime()),
minutesFromSeconds(GM->gameTime()),
secondsFromSeconds(GM->gameTime()));
}
stf::smv::IView *EndView::keyEventsHandler(const int)
{
static_cast<GameModel*>(m_model)->reset();
return new MenuView(static_cast<GameModel*>(m_model));
}
CloseView::CloseView(GameModel *model)
: stf::smv::IView(model) {}
bool CloseView::isContinue() const
{
return false;
}