-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameOverUIPanel.cpp
61 lines (51 loc) · 1.19 KB
/
GameOverUIPanel.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "GameOverUIPanel.h"
#include "GameScreen.h"
bool GameScreen::m_GameOver;
GameOverUIPanel::GameOverUIPanel(Vector2i res) :
UIPanel(res,
(res.x / 10) * 3,
res.y / 2, // 50% of the resolution from the top
(res.x / 10) * 3, // as wide as 1/3 of the resolution
res.y / 6, // and as tall as 1/6 of the resolution
50, 255, 255, 255) // a, r, g, b
{
m_ButtonWidth = res.x / 20;
m_ButtonHeight = res.y / 20;
m_ButtonPadding = res.x / 100;
m_Text.setFillColor(sf::Color(0, 255, 0, 255));// Green
m_Text.setString("GAME OVER!");
m_Font.loadFromFile("fonts/Roboto-Bold.ttf");
m_Text.setFont(m_Font);
m_Text.setPosition(Vector2f(m_ButtonPadding,
(m_ButtonPadding * 2) + m_ButtonHeight));
m_Text.setCharacterSize(60);
initialiseButtons();
}
void GameOverUIPanel::initialiseButtons()
{
addButton(m_ButtonPadding,
m_ButtonPadding,
m_ButtonWidth,
m_ButtonHeight,
0, 255, 0,
"Play");
addButton(m_ButtonWidth + (m_ButtonPadding * 2),
m_ButtonPadding,
m_ButtonWidth,
m_ButtonHeight,
255, 0, 0,
"Home");
}
void GameOverUIPanel::draw(RenderWindow& window)
{
if (GameScreen::m_GameOver)
{
show();
UIPanel::draw(window);
window.draw(m_Text);
}
else
{
hide();
}
}