-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHUD.cpp
More file actions
54 lines (41 loc) · 1.01 KB
/
Copy pathHUD.cpp
File metadata and controls
54 lines (41 loc) · 1.01 KB
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
#include "HUD.h"
#include "Shared.h"
#include "Window.h"
HUD::HUD(Shared* shared)
: m_shared(shared)
{
m_font.loadFromFile("./Graphics/KOMIKAP.ttf");
m_time.setFont(m_font);
m_blocks.setFont(m_font);
m_blocks.setPosition(30, 20);
}
void HUD::initialise(int blocks)
{
m_blocksToPaint = blocks;
m_blocks.setString("1/" + std::to_string(m_blocksToPaint));
m_time.setString("0s");
onResize();
}
void HUD::update(float dT, int playerSize)
{
m_time.setString(std::to_string(static_cast<int>(dT)) + "s");
m_blocks.setString(std::to_string(playerSize) + '/' + std::to_string(m_blocksToPaint));
}
void HUD::draw()
{
m_shared->m_window->draw(m_time);
m_shared->m_window->draw(m_blocks);
}
void HUD::onResize()
{
if (m_shared->m_window->getSize().x >= 600) {
m_time.setCharacterSize(32);
m_blocks.setCharacterSize(32);
}
else {
m_time.setCharacterSize(20);
m_blocks.setCharacterSize(20);
}
m_time.setOrigin(m_time.getLocalBounds().width, 0);
m_time.setPosition(m_shared->m_window->getSize().x - 30, 20);
}