-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGui.cpp
More file actions
58 lines (41 loc) · 1.31 KB
/
Copy pathGui.cpp
File metadata and controls
58 lines (41 loc) · 1.31 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
55
56
57
58
#include "Gui.h"
CountGui::CountGui()
{
textureCount.loadFromFile("img/GUI/numbs.png");
textureZombieHeadIco.loadFromFile("img/GUI/zombie_head_ico.png");
spriteZombieHeadIco.setTexture(textureZombieHeadIco);
spriteZombieHeadIco.setPosition(0, 0);
spriteZombieHeadIco.setScale(0.1f, 0.1f);
spriteCounts.reserve(10);
for (int numCount = 0; numCount < 10; numCount++) {
Sprite spriteCount;
spriteCount.setTexture(textureCount);
spriteCount.setTextureRect(IntRect(advance[numCount], 400, 146, 201));
spriteCount.setPosition(0, 0);
spriteCount.setScale(0.5f, 0.5f);
spriteCounts.push_back(spriteCount);
}
}
void CountGui::setKills(int kills)
{
kills_count = kills;
str = std::to_string(kills_count);
numCounts.clear();
numCounts.reserve(str.size());
float x = posX;
for (int strCount = 0; strCount < str.size(); strCount++) {
int digit = str[strCount] - '0';
if (digit < 0 || digit > 9) continue;
sf::Sprite s = spriteCounts[digit];
s.setPosition(x, posY);
numCounts.push_back(s);
x += spacing;
}
}
void CountGui::drawGui(sf::RenderWindow &window)
{
for (auto& CountKills : numCounts) {
window.draw(CountKills);
}
window.draw(spriteZombieHeadIco);
}