-
Notifications
You must be signed in to change notification settings - Fork 2
/
sfml_zen_bar.cpp
49 lines (41 loc) · 1.25 KB
/
sfml_zen_bar.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
#include "sfml_zen_bar.h"
#include "sfml_resources.h"
sfml_zen_bar::sfml_zen_bar()
{
m_zen_bar.setSize(sf::Vector2f(sfml_resources::get().get_zen_bar().getSize()));
m_zen_bar.setTexture(&sfml_resources::get().get_zen_bar());
m_zen_icon.setSize(sf::Vector2f(sfml_resources::get().get_zen_ind().getSize()));
m_zen_icon.setTexture(&sfml_resources::get().get_zen_ind());
}
sf::RectangleShape sfml_zen_bar::get_drawable_bar(
float x_pos,
float y_pos,
sf::RenderWindow &window)
{
m_zen_bar.setPosition(sf::Vector2f(
(x_pos - (m_zen_bar.getSize().x/2.0f)),
y_pos));
m_zen_bar.setPosition(window.mapPixelToCoords(sf::Vector2i(m_zen_bar.getPosition())));
return m_zen_bar;
}
sf::RectangleShape sfml_zen_bar::get_drawable_ind(
float x_pos,
float y_pos,
sf::RenderWindow &window
)
{
m_zen_icon.setPosition(
sf::Vector2f(
x_pos - (m_zen_icon.getSize().x/2.0f) + m_zen_balance,
y_pos + (m_zen_bar.getSize().y/2.0f) - (m_zen_icon.getSize().x/2.0f)
)
);
m_zen_icon.setPosition(
window.mapPixelToCoords(sf::Vector2i(m_zen_icon.getPosition()))
);
return m_zen_icon;
}
void sfml_zen_bar::set_score(const double score)
{
m_zen_balance = score;
}