-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScore.cpp
40 lines (33 loc) · 794 Bytes
/
Score.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
#include <string>
#include "Score.h"
#include "Assets.h"
#include "Settings.h"
Score::Score()
{
m_scoreText.setFont(Assets::Instance().getHyperspaceFont());
m_scoreText.setFillColor(sf::Color::White);
m_scoreText.setCharacterSize(50);
m_scoreText.setPosition(10.f, 10.f);
m_numberOfPoints = 0;
}
void Score::addPoints(AsteroidType asteroidType)
{
if (asteroidType == AsteroidType::Big)
m_numberOfPoints += 50;
else if (asteroidType == AsteroidType::Small)
m_numberOfPoints += 100;
}
void Score::render(sf::RenderWindow* renderWindow)
{
m_scoreText.setString(std::to_string(m_numberOfPoints));
renderWindow->draw(m_scoreText);
}
sf::Text& Score::getText()
{
m_scoreText.setString(m_numberOfPoints);
return m_scoreText;
}
void Score::scoreZero()
{
m_numberOfPoints = 0;
}