-
Notifications
You must be signed in to change notification settings - Fork 0
/
End.cpp
80 lines (63 loc) · 1.82 KB
/
End.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "End.h"
#include "GameComponents.h"
#include "Logger.h"
#include "Projector.h"
End::End()
{
Logger::get() << "Initializing the end slide...\n";
}
SlideType End::getNextSlide()
{
if (IsKeyDown(VK_SPACE))
{
return SlideType::level01;
}
return SlideType::end;
}
void End::reset()
{
Score& score = GameComponents::get().getScore();
timeValue.setText(std::to_string(Timer::accumulatedTime) + " ms");
scoreValue.setText(std::to_string(score.getScore()) + " pt");
// Compute time bonus
if (Timer::accumulatedTime < 60000)
{
int bonus = 60000 - Timer::accumulatedTime;
timeBonusValue.setText(std::to_string(bonus) + " pt");
score.addPoints(bonus);
}
else
{
timeBonusValue.setText("0 pt");
}
totalScoreValue.setText(std::to_string(score.getScore()) + " pt");
const int topScore = score.getTopScore();
if (topScore < score.getScore())
{
firstPlace.setText("you: " + std::to_string(score.getScore()));
secondPlace.setText("2nd: " + std::to_string(topScore));
newHightScore.setText("new high score congrats");
score.saveScore(score.getScore());
}
else
{
firstPlace.setText("1st: " + std::to_string(topScore));
secondPlace.setText("you: " + std::to_string(score.getScore()));
newHightScore.setText("not so bad");
}
}
void End::tick(const Time currentTime)
{
header.tick(currentTime);
time.tick(currentTime);
timeBonus.tick(currentTime);
score.tick(currentTime);
totalScore.tick(currentTime);
timeValue.tick(currentTime);
timeBonusValue.tick(currentTime);
scoreValue.tick(currentTime);
totalScoreValue.tick(currentTime);
firstPlace.tick(currentTime);
secondPlace.tick(currentTime);
newHightScore.tick(currentTime);
}