commit 4379ec19
Started to create different starting speeds for Endless. Needs heavy tweaking.
Changed files
diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp
index 49291a1..a16b58c 100644
--- a/source/code/BlockGame.cpp
+++ b/source/code/BlockGame.cpp
@@ -154,19 +154,19 @@ void BlockGame::setGameSpeed(int globalSpeedLevel) {
baseSpeed=0.5;
break;
case 1:
- baseSpeed=0.4;
+ baseSpeed=0.3;
break;
case 2:
- baseSpeed=0.3;
+ baseSpeed=0.1;
break;
case 3:
- baseSpeed=0.25;
+ baseSpeed=0.07;
break;
case 4:
- baseSpeed=0.2;
+ baseSpeed=0.04;
break;
default:
- baseSpeed=0.15;
+ baseSpeed=0.015;
break;
};
}
@@ -269,7 +269,7 @@ void BlockGame::NewGame(const BlockGameStartInfo& s) {
if (s.AI) {
recordStats = false;
}
- NewGame(s.ticks);
+ NewGameInternal(s.ticks);
if (s.timeTrial) {
timetrial = true;
putStartBlocks();
@@ -333,11 +333,12 @@ void BlockGame::NewGame(const BlockGameStartInfo& s) {
}
if (s.gameSpeed > 0) {
setGameSpeed(s.gameSpeed);
+ speed = baseSpeed;
}
}
//Instead of creating new object new game is called, to prevent memory leaks
-void BlockGame::NewGame( unsigned int ticks) {
+void BlockGame::NewGameInternal( unsigned int ticks) {
this->ticks = ticks;
stageButtonStatus = SBdontShow;
nrFellDown = 0;
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index 5ab77d7..db90d9b 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -265,7 +265,7 @@ public:
return replayInfo;
}
private:
- void NewGame(unsigned int ticks);
+ void NewGameInternal(unsigned int ticks);
//Test if LineNr is an empty line, returns false otherwise.
bool LineEmpty(int lineNr) const;
//Test if the entire board is empty (used for Puzzles)
diff --git a/source/code/global.hpp b/source/code/global.hpp
index 0541109..5724f99 100644
--- a/source/code/global.hpp
+++ b/source/code/global.hpp
@@ -68,8 +68,8 @@ struct GlobalData {
bool highPriority = false;
bool NoSound = false;
int verboseLevel = 0;
- Highscore theTopScoresEndless; //Stores highscores for endless
- Highscore theTopScoresTimeTrial; //Stores highscores for timetrial
+ Highscore theTopScoresEndless = Highscore(0.5); //Stores highscores for endless
+ Highscore theTopScoresTimeTrial = Highscore(0.5); //Stores highscores for timetrial
std::unique_ptr<sago::SagoSpriteHolder> spriteHolder;
TextManager theTextManager;
diff --git a/source/code/highscore.cpp b/source/code/highscore.cpp
index d12e685..b37d5f5 100644
--- a/source/code/highscore.cpp
+++ b/source/code/highscore.cpp
@@ -50,7 +50,7 @@ bool record_sorter (const record& i,const record& j) {
return (i.score > j.score);
}
-Highscore::Highscore(const std::string& type) : filename(type+".json.dat"), type(type) {
+Highscore::Highscore(const std::string& type, double speed) : filename(type+".json.dat"), type(type), speed(speed) {
std::string readFileContent = sago::GetFileContent(filename.c_str());
if (readFileContent.length() > 0) {
try {
diff --git a/source/code/highscore.h b/source/code/highscore.h
index 5012b69..dd40723 100644
--- a/source/code/highscore.h
+++ b/source/code/highscore.h
@@ -46,13 +46,14 @@ private:
std::string filename;
std::string type;
void writeFile();
+ double speed = 0.5;
public:
- Highscore()
+ Highscore(double speed) : speed(speed)
{
}
- Highscore(const std::string& type);
+ Highscore(const std::string& type, double speed);
bool isHighScore(int);
void addScore(const std::string& newName, int);
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 1a9996d..7a7f6c9 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -674,11 +674,15 @@ static bool registerTTHighscorePlayer1 = false;
static bool registerTTHighscorePlayer2 = false;
static bool saveReplay = false;
-static void StartSinglePlayerEndless() {
+/**
+ * startSpeed is a value from 0 to 4
+ * */
+static void StartSinglePlayerEndless(int startSpeed) {
//1 player - endless
BlockGameStartInfo startInfo;
startInfo.ticks = SDL_GetTicks();
startInfo.startBlocks = startInfo.ticks;
+ startInfo.gameSpeed = startSpeed;
player1->NewGame(startInfo);
twoPlayers =false;
BlockGameAction a;
@@ -943,8 +947,8 @@ int main(int argc, char* argv[]) {
globalData.SoundEnabled = true;
globalData.MusicEnabled = true;
twoPlayers = false; //true if two players splitscreen
- globalData.theTopScoresEndless = Highscore("endless");
- globalData.theTopScoresTimeTrial = Highscore("timetrial");
+ globalData.theTopScoresEndless = Highscore("endless", 0.5);
+ globalData.theTopScoresTimeTrial = Highscore("timetrial", 0.5);
drawBalls = true;
puzzleLoaded = false;
theBallManager = BallManager();
@@ -1203,8 +1207,8 @@ int main(int argc, char* argv[]) {
}
int runGame(Gametype gametype, int level) {
- globalData.theTopScoresEndless = Highscore("endless");
- globalData.theTopScoresTimeTrial = Highscore("timetrial");
+ globalData.theTopScoresEndless = Highscore("endless", 0.5);
+ globalData.theTopScoresTimeTrial = Highscore("timetrial", 0.5);
drawBalls = true;
puzzleLoaded = false;
bool bNearDeath = false; //Play music faster or louder while tru
@@ -1302,7 +1306,7 @@ int runGame(Gametype gametype, int level) {
break;
case Gametype::SinglePlayerEndless:
default:
- StartSinglePlayerEndless();
+ StartSinglePlayerEndless(level);
};
mustsetupgame = false;
DrawBackground(globalData.screen);
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp
index cf3a25a..837278f 100644
--- a/source/code/menudef.cpp
+++ b/source/code/menudef.cpp
@@ -138,10 +138,52 @@ void InitMenues() {
standardButton.setSurfaces();
}
-static void runSinglePlayerEndless() {
+static void runSinglePlayerEndless0() {
runGame(Gametype::SinglePlayerEndless, 0);
}
+static void runSinglePlayerEndless1() {
+ runGame(Gametype::SinglePlayerEndless, 1);
+}
+
+static void runSinglePlayerEndless2() {
+ runGame(Gametype::SinglePlayerEndless, 2);
+}
+
+static void runSinglePlayerEndless3() {
+ runGame(Gametype::SinglePlayerEndless, 3);
+}
+
+static void runSinglePlayerEndless4() {
+ runGame(Gametype::SinglePlayerEndless, 4);
+}
+
+static void runSinglePlayerEndless() {
+ Menu sp(globalData.screen,_("Single Player Endless"),true);
+ Button d0,d1,d2,d3,d4;
+ d0.setPopOnRun(true);
+ d1.setPopOnRun(true);
+ d2.setPopOnRun(true);
+ d3.setPopOnRun(true);
+ d4.setPopOnRun(true);
+ d0.setLabel(_("Slow"));
+ d1.setLabel(_("Fast"));
+ d2.setLabel(_("Faster"));
+ d3.setLabel(_("Even faster"));
+ d4.setLabel(_("Fastest"));
+ d0.setAction(runSinglePlayerEndless0);
+ d1.setAction(runSinglePlayerEndless1);
+ d2.setAction(runSinglePlayerEndless2);
+ d3.setAction(runSinglePlayerEndless3);
+ d4.setAction(runSinglePlayerEndless4);
+ sp.addButton(&d0);
+ sp.addButton(&d1);
+ sp.addButton(&d2);
+ sp.addButton(&d3);
+ sp.addButton(&d4);
+ RunGameState(sp);
+}
+
static void runSinglePlayerTimeTrial() {
runGame(Gametype::SinglePlayerTimeTrial, 0);
}