-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIngamebar.cpp
More file actions
48 lines (39 loc) · 1.47 KB
/
Ingamebar.cpp
File metadata and controls
48 lines (39 loc) · 1.47 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
#include "Ingamebar.hpp"
#include <string>
#include "Core.hpp"
namespace rpf {
IngameBar::IngameBar(ResourceHolder* rh) {
this->rh = rh;
panel.setSize(sf::Vector2f(rh->s_width, 100));
panel.setFillColor(sf::Color(0x00000055));
life.setTexture(rh->player_idle[0], true);
life.setScale(0.2, 0.2);
life.setPosition(10, 10);
life_text.setFont(rh->font);
life_text.setString("x3");
life_text.setOrigin(0, life_text.getLocalBounds().height * 2);
life_text.setPosition(120, 100);
score.setFont(rh->font);
score.setString(L"¤À¼Æ: 0");
score.setCharacterSize(60U);
score.setOrigin(0, score.getLocalBounds().height / 2);
score.setPosition(600, 50);
highest_score.setFont(rh->font);
highest_score.setString(L"¾ú¥v°ª¤À: 0");
highest_score.setCharacterSize(60U);
highest_score.setOrigin(0, score.getLocalBounds().height / 2);
highest_score.setPosition(1000, 50);
nowx = rh->s_width / 2;
}
void IngameBar::update(int scores, int lifes) {
panel.move(rh->view->getCenter().x - nowx, 0);
life.move(rh->view->getCenter().x - nowx, 0);
life_text.move(rh->view->getCenter().x - nowx, 0);
score.move(rh->view->getCenter().x - nowx, 0);
highest_score.move(rh->view->getCenter().x - nowx, 0);
life_text.setString("x" + std::to_string(lifes));
score.setString(L"¤À¼Æ: " + std::to_wstring(scores));
highest_score.setString(L"¾ú¥v°ª¤À: " + std::to_wstring(Core::highest_score));
nowx = rh->view->getCenter().x;
}
}