-
Notifications
You must be signed in to change notification settings - Fork 1
/
HUD.cpp
42 lines (38 loc) · 1.29 KB
/
HUD.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
#include "HUD.hpp"
#include <string>
namespace APlusPlus
{
HUD::HUD(GameDataRef data) : _data(data)
{
_scoreText.setFont(this->_data->assets.GetFont("Flappy Font"));
_scoreText.setString("0");
_scoreText.setCharacterSize(128);
_scoreText.setFillColor(sf::Color::White);
_scoreText.setOrigin(sf::Vector2f(_scoreText.getGlobalBounds().width / 2, _scoreText.getGlobalBounds().height / 2));
_scoreText.setPosition(sf::Vector2f(_data->window.getSize().x / 2, _data->window.getSize().y / 5));
}
HUD::~HUD() {}
void HUD::Draw()
{
_data->window.draw(_scoreText);
}
void HUD::UpdateScore(int score)
{
_scoreText.setString(std::to_string(score));
if(score == FIRST_THRESHOLD ){
_scoreText.setFillColor(sf::Color(250,235,215));
}
else if(score == SECOND_THRESHOLD){
_scoreText.setFillColor(sf::Color(255,127,80));
}
else if(score == THIRD_THRESHOLD){
_scoreText.setFillColor(sf::Color(8,46,84));
}
else if(score == FORTH_THRESHOLD){
_scoreText.setFillColor(sf::Color(189,252,201));
}
else if(score == FIFTH_THRESHOLD){
_scoreText.setFillColor(sf::Color(255,215,0));
}
}
}