-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameOverScreen.cpp
More file actions
96 lines (70 loc) · 2.43 KB
/
Copy pathgameOverScreen.cpp
File metadata and controls
96 lines (70 loc) · 2.43 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "gameOverScreen.h"
gameOverScreen::gameOverScreen()
{
textureForTitle.loadFromFile("img/GameOver/gameOverScreen.png");
image.setTexture(textureForTitle);
image.scale(0.66f, 0.66f);
image.setPosition(-50, 0);
textureForTitleKill_st.loadFromFile("img/GameOver/kill_st.png");
imageKill_st.setTexture(textureForTitleKill_st);
imageKill_st.scale(0.4f, 0.4f);
imageKill_st.setPosition(140, 80);
// Ïðîñòàÿ áåëàÿ êíîïêà
restartButton.setSize(sf::Vector2f(200, 60));
restartButton.setFillColor(sf::Color::Transparent);
/*restartButton.setOutlineThickness(3);
restartButton.setOutlineColor(sf::Color::White); */
restartButton.setPosition(178, 545);
// Ïðîñòàÿ áåëàÿ êíîïêà
exitButton.setSize(sf::Vector2f(200, 60));
exitButton.setFillColor(sf::Color::Transparent);
/*exitButton.setOutlineThickness(3);
exitButton.setOutlineColor(sf::Color::White); */
exitButton.setPosition(530, 545);
textureCount_st.loadFromFile("img/GameOver/numbs_st.png");
spriteCounts_st.reserve(10);
for (int numCount_st = 0; numCount_st < 10; numCount_st++) {
sf::Sprite AddSpriteCount_st;
AddSpriteCount_st.setTexture(textureCount_st);
AddSpriteCount_st.setTextureRect(sf::IntRect(advance[numCount_st], 400, 146, 201));
AddSpriteCount_st.setPosition(0, 0);
AddSpriteCount_st.setScale(0.5f, 0.5f);
spriteCounts_st.push_back(AddSpriteCount_st);
}
}
void gameOverScreen::setKillsST(int killsST)
{
kills_count_st = killsST;
str_st = std::to_string(kills_count_st);
numCountsST.clear();
numCountsST.reserve(str_st.size());
if (kills_count_st >= shiftNumForKillST){
shiftNumForKillST *= 10;
posX -= spacing/2;
}
float x = posX;
for (int strCountST = 0; strCountST < str_st.size(); strCountST++) {
int digitST = str_st[strCountST] - '0';
if (digitST < 0 || digitST > 9) continue;
sf::Sprite s = spriteCounts_st[digitST];
s.setPosition(x, posY);
numCountsST.push_back(s);
x += spacing;
}
}
void gameOverScreen::DrawGameOver(sf::RenderWindow& window)
{
window.draw(image);
window.draw(imageKill_st);
for (auto& CountKillsST : numCountsST) {
window.draw(CountKillsST);
}
}
sf::RectangleShape& gameOverScreen::GetRestartButton()
{
return restartButton;
}
sf::RectangleShape& gameOverScreen::GetExitButton()
{
return exitButton;
}