git repos / blockattack-game

commit 905de2a2

sago007 · 2019-02-08 18:46
905de2a2ff75afc048f824ef569875fe501a68e2 patch · browse files
parent 548313f71f175cd119c27a54859a0fa32b80f258

Removed the time trial structs from global variables

Changed files

M source/code/ScoresDisplay.cpp before
M source/code/ScoresDisplay.hpp before
M source/code/global.hpp before
M source/code/main.cpp before
diff --git a/source/code/ScoresDisplay.cpp b/source/code/ScoresDisplay.cpp index 71db447..a90ddea 100644 --- a/source/code/ScoresDisplay.cpp +++ b/source/code/ScoresDisplay.cpp
@@ -72,10 +72,10 @@ void ScoresDisplay::DrawHighscores(int x, int y, bool endless) {
for (int i =0; i<10; i++) {
record r;
if (endless) {
- r = globalData.theTopScoresEndless.getScoreNumber(i);
+ r = theTopScoresEndless.getScoreNumber(i);
}
else {
- r = globalData.theTopScoresTimeTrial.getScoreNumber(i);
+ r = theTopScoresTimeTrial.getScoreNumber(i);
}
char playerScore[32];
char playerName[32];
diff --git a/source/code/ScoresDisplay.hpp b/source/code/ScoresDisplay.hpp index 90a9b31..1e96864 100644 --- a/source/code/ScoresDisplay.hpp +++ b/source/code/ScoresDisplay.hpp
@@ -28,6 +28,7 @@ http://www.blockattack.net
#include "sago/SagoTextField.hpp"
#include <map>
#include <memory>
+#include "highscore.h"
class ScoresDisplay : public sago::GameStateInterface {
public:
@@ -46,6 +47,8 @@ public:
int scoreY = 0;
int buttonXsize = 0;
int buttonYsize = 0;
+ Highscore theTopScoresEndless = Highscore("endless", 0.5); //Stores highscores for endless
+ Highscore theTopScoresTimeTrial = Highscore("timetrial", 0.5); //Stores highscores for timetrial
private:
void DrawHighscores(int x, int y, bool endless);
void DrawStats();
diff --git a/source/code/global.hpp b/source/code/global.hpp index 0d93790..37848a7 100644 --- a/source/code/global.hpp +++ b/source/code/global.hpp
@@ -68,8 +68,6 @@ struct GlobalData {
bool highPriority = false;
bool NoSound = false;
int verboseLevel = 0;
- Highscore theTopScoresEndless = Highscore("endless", 0.5); //Stores highscores for endless
- Highscore theTopScoresTimeTrial = Highscore("timetrial", 0.5); //Stores highscores for timetrial
std::unique_ptr<sago::SagoSpriteHolder> spriteHolder;
TextManager theTextManager;
diff --git a/source/code/main.cpp b/source/code/main.cpp index 7a7f6c9..784483a 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -947,8 +947,6 @@ int main(int argc, char* argv[]) {
globalData.SoundEnabled = true;
globalData.MusicEnabled = true;
twoPlayers = false; //true if two players splitscreen
- globalData.theTopScoresEndless = Highscore("endless", 0.5);
- globalData.theTopScoresTimeTrial = Highscore("timetrial", 0.5);
drawBalls = true;
puzzleLoaded = false;
theBallManager = BallManager();
@@ -1207,8 +1205,8 @@ int main(int argc, char* argv[]) {
}
int runGame(Gametype gametype, int level) {
- globalData.theTopScoresEndless = Highscore("endless", 0.5);
- globalData.theTopScoresTimeTrial = Highscore("timetrial", 0.5);
+ Highscore theTopScoresEndless = Highscore("endless", 0.5);
+ Highscore theTopScoresTimeTrial = Highscore("timetrial", 0.5);
drawBalls = true;
puzzleLoaded = false;
bool bNearDeath = false; //Play music faster or louder while tru
@@ -1728,15 +1726,15 @@ int runGame(Gametype gametype, int level) {
if (theGame.isGameOver() && registerTTHighscorePlayer1) {
registerTTHighscorePlayer1 = false;
- globalData.theTopScoresTimeTrial.addScore(theGame.name, theGame.GetScore());
+ theTopScoresTimeTrial.addScore(theGame.name, theGame.GetScore());
}
if (theGame2.isGameOver() && registerTTHighscorePlayer2) {
registerTTHighscorePlayer2 = false;
- globalData.theTopScoresTimeTrial.addScore(theGame2.name, theGame2.GetScore());
+ theTopScoresTimeTrial.addScore(theGame2.name, theGame2.GetScore());
}
if (theGame.isGameOver() && registerEndlessHighscore) {
registerEndlessHighscore = false;
- globalData.theTopScoresEndless.addScore(theGame.name, theGame.GetScore());
+ theTopScoresEndless.addScore(theGame.name, theGame.GetScore());
theGame.EndlessHighscoreEvent();
}
#ifdef REPLAY_IMPLEMENTED