git repos / blockattack-game

commit 79d552fa

sago007 · 2019-02-12 17:17
79d552faeaa25076bdf8858c68be4645d58b04a5 patch · browse files
parent b53216363af12b4a7921c1634e7902d0bffaa3fd

Now with highscore list for all difficulties.

Changed files

M source/code/ScoresDisplay.cpp before
M source/code/ScoresDisplay.hpp before
diff --git a/source/code/ScoresDisplay.cpp b/source/code/ScoresDisplay.cpp index a90ddea..429b0d0 100644 --- a/source/code/ScoresDisplay.cpp +++ b/source/code/ScoresDisplay.cpp
@@ -51,7 +51,7 @@ void ScoresDisplay::Write(SDL_Renderer* target, int x, int y, const char* text)
getCachedText(text)->Draw(target, x, y);
}
-const int numberOfPages = 3;
+const int numberOfPages = 7;
void ScoresDisplay::DrawBackgroundAndCalcPlacements() {
DrawBackground(globalData.screen);
@@ -61,10 +61,11 @@ void ScoresDisplay::DrawBackgroundAndCalcPlacements() {
}
//Draws the highscores
-void ScoresDisplay::DrawHighscores(int x, int y, bool endless) {
+void ScoresDisplay::DrawHighscores(int x, int y, bool endless, int level = 0) {
DrawBackgroundAndCalcPlacements();
if (endless) {
- Write(globalData.screen, x+100,y+100, _("Endless:") );
+ std::string header = SPrintStringF(_("Endless (%s):"), std::to_string(level).c_str());
+ Write(globalData.screen, x+100,y+100, header.c_str() );
}
else {
Write(globalData.screen, x+100,y+100, _("Time Trial:") );
@@ -72,7 +73,22 @@ void ScoresDisplay::DrawHighscores(int x, int y, bool endless) {
for (int i =0; i<10; i++) {
record r;
if (endless) {
- r = theTopScoresEndless.getScoreNumber(i);
+ switch(level) {
+ case 1:
+ r = theTopScoresEndless1.getScoreNumber(i);
+ break;
+ case 2:
+ r = theTopScoresEndless2.getScoreNumber(i);
+ break;
+ case 3:
+ r = theTopScoresEndless3.getScoreNumber(i);
+ break;
+ case 4:
+ r = theTopScoresEndless4.getScoreNumber(i);
+ break;
+ default:
+ r = theTopScoresEndless0.getScoreNumber(i);
+ }
}
else {
r = theTopScoresTimeTrial.getScoreNumber(i);
@@ -159,17 +175,21 @@ bool ScoresDisplay::IsActive() {
void ScoresDisplay::Draw(SDL_Renderer*) {
switch (page) {
- case 0:
- //Highscores, endless
- DrawHighscores(100,100,true);
- break;
- case 1:
- //Highscores, Time Trial
- DrawHighscores(100,100,false);
- break;
- case 2:
- default:
- DrawStats();
+ case 0:
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ //Highscores, endless
+ DrawHighscores(100,100,true, page);
+ break;
+ case 5:
+ //Highscores, Time Trial
+ DrawHighscores(100,100,false);
+ break;
+ case 6:
+ default:
+ DrawStats();
};
const sago::SagoDataHolder* holder = &globalData.spriteHolder->GetDataHolder();
@@ -193,7 +213,7 @@ void ScoresDisplay::ProcessInput(const SDL_Event& event, bool& processed) {
UpdateMouseCoordinates(event, globalData.mousex, globalData.mousey);
- if (isLeftEvent(event)) {
+ if (isRightEvent(event)) {
page++;
if (page>=numberOfPages) {
page = 0;
@@ -201,7 +221,7 @@ void ScoresDisplay::ProcessInput(const SDL_Event& event, bool& processed) {
processed = true;
}
- if (isRightEvent(event)) {
+ if (isLeftEvent(event)) {
page--;
if (page<0) {
page = numberOfPages-1;
diff --git a/source/code/ScoresDisplay.hpp b/source/code/ScoresDisplay.hpp index 1e96864..8c4d42b 100644 --- a/source/code/ScoresDisplay.hpp +++ b/source/code/ScoresDisplay.hpp
@@ -47,10 +47,14 @@ public:
int scoreY = 0;
int buttonXsize = 0;
int buttonYsize = 0;
- Highscore theTopScoresEndless = Highscore("endless", 0.5); //Stores highscores for endless
+ Highscore theTopScoresEndless0 = Highscore("endless", 0.5); //Stores highscores for endless
+ Highscore theTopScoresEndless1 = Highscore("endless", 0.1); //Stores highscores for endless
+ Highscore theTopScoresEndless2 = Highscore("endless", 0.07); //Stores highscores for endless
+ Highscore theTopScoresEndless3 = Highscore("endless", 0.04); //Stores highscores for endless
+ Highscore theTopScoresEndless4 = Highscore("endless", 0.015); //Stores highscores for endless
Highscore theTopScoresTimeTrial = Highscore("timetrial", 0.5); //Stores highscores for timetrial
private:
- void DrawHighscores(int x, int y, bool endless);
+ void DrawHighscores(int x, int y, bool endless, int speedLevel);
void DrawStats();
void DrawBackgroundAndCalcPlacements();
void Write(SDL_Renderer* target, int x, int y, const char* text);