-
Notifications
You must be signed in to change notification settings - Fork 1
/
Score.cpp
65 lines (57 loc) · 996 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
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
#include "Score.h"
#include "FontString.h"
namespace RTG
{
Score::Score() : m_MAPILString(),
m_Score( 0 ),
m_RestScore( 0 )
{
}
Score::~Score()
{
m_Score = 0;
m_RestScore = 0;
}
void Score::Display( float x, float y, float offset, int digit ) const
{
MAPIL::BeginRendering2DGraphics();
FontString s;
char str[ 10 ];
sprintf( str, "%%0%dd", digit );
s.Set( str, m_Score );
s.Draw( x, y, 0.5f, 0xFFFFDDAA );
MAPIL::EndRendering2DGraphics();
}
void Score::Add( int score )
{
m_RestScore += score;
}
void Score::Set( int score )
{
m_Score = score;
m_RestScore = 0;
}
int Score::Get() const
{
return m_Score;
}
void Score::Update()
{
if( m_RestScore >= 50000 ){
m_Score += 50000;
m_RestScore -= 50000;
}
else if( m_RestScore >= 5000 ){
m_Score += 5000;
m_RestScore -= 5000;
}
else if( m_RestScore >= 50 ){
m_Score += 50;
m_RestScore -= 50;
}
else{
m_Score += m_RestScore;
m_RestScore = 0;
}
}
}