-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHUD.cpp
67 lines (54 loc) · 1.27 KB
/
HUD.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
62
63
64
65
66
67
#include "Hud.h"
Hud::Hud()
{
Vector2u resolution;
resolution.x = VideoMode::getDesktopMode().width;
resolution.y = VideoMode::getDesktopMode().height;
// Load the font
m_Font.loadFromFile("fonts/Roboto-Light.ttf");
// when Paused
m_StartText.setFont(m_Font);
m_StartText.setCharacterSize(100);
m_StartText.setFillColor(Color::White);
m_StartText.setString("Press Enter when ready!");
// Position the text
FloatRect textRect = m_StartText.getLocalBounds();
m_StartText.setOrigin(textRect.left +
textRect.width / 2.0f,
textRect.top +
textRect.height / 2.0f);
m_StartText.setPosition(
resolution.x / 2.0f, resolution.y / 2.0f);
// Time
m_TimeText.setFont(m_Font);
m_TimeText.setCharacterSize(75);
m_TimeText.setFillColor(Color::White);
m_TimeText.setPosition(resolution.x - 150, 0);
m_TimeText.setString("------");
// Level
m_LevelText.setFont(m_Font);
m_LevelText.setCharacterSize(75);
m_LevelText.setFillColor(Color::White);
m_LevelText.setPosition(25, 0);
m_LevelText.setString("1");
}
Text Hud::getMessage()
{
return m_StartText;
}
Text Hud::getLevel()
{
return m_LevelText;
}
Text Hud::getTime()
{
return m_TimeText;
}
void Hud::setLevel(String text)
{
m_LevelText.setString(text);
}
void Hud::setTime(String text)
{
m_TimeText.setString(text);
}