commit c1785ec5
Moved the next level method out of BlockGame
Changed files
| M | source/code/BlockGame.cpp before |
| M | source/code/BlockGame.hpp before |
| M | source/code/main.cpp before |
diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp
index 59c44eb..767a916 100644
--- a/source/code/BlockGame.cpp
+++ b/source/code/BlockGame.cpp
@@ -347,23 +347,6 @@ void BlockGame::NewPuzzleGame(int level, unsigned int ticks) {
}
}
-//Play the next level
-void BlockGame::nextLevel(unsigned int ticks) {
- if (puzzleMode) {
- if (Level<PuzzleGetNumberOfPuzzles()-1) {
- NewPuzzleGame(Level+1, ticks);
- }
- }
- else if (stageClear) {
- if (Level<50-1) {
- BlockGameStartInfo s;
- s.ticks = ticks;
- s.stageClear = true;
- s.level = Level+1;
- NewGame(s);
- }
- }
-}
//Starts new Vs Game (two Player)
void BlockGame::NewVsGame(BlockGame* target, unsigned int ticks) {
@@ -1941,6 +1924,23 @@ int BlockGame::getLevel() const {
return Level;
}
+//Play the next level
+void nextLevel(BlockGame& g, unsigned int ticks) {
+ if (g.isPuzzleMode()) {
+ if (g.getLevel()<PuzzleGetNumberOfPuzzles()-1) {
+ g.NewPuzzleGame(g.getLevel()+1, ticks);
+ }
+ }
+ else if (g.isStageClear()) {
+ if (g.getLevel() < 50-1) {
+ BlockGameStartInfo s;
+ s.ticks = ticks;
+ s.stageClear = true;
+ s.level = g.getLevel()+1;
+ g.NewGame(s);
+ }
+ }
+}
void retryLevel(BlockGame& g, unsigned int ticks) {
BlockGameStartInfo s;
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index bdb93f5..352b444 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -184,8 +184,6 @@ public:
bool GetIsWinner() const;
void NewGame(const BlockGameStartInfo &s);
void NewPuzzleGame(int level, unsigned int ticks);
- //Play the next level
- void nextLevel(unsigned int ticks);
//Starts new Vs Game (two Player)
void NewVsGame(BlockGame *target,unsigned int ticks);
//Starts new Vs Game (two Player)
@@ -294,6 +292,8 @@ private:
void UpdateInternal(unsigned int newtick);
};
+//Play the next level
+void nextLevel(BlockGame& g, unsigned int ticks);
//Replay the current level
void retryLevel(BlockGame& g, unsigned int ticks);
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 557ea80..0316644 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -2297,7 +2297,8 @@ int runGame(int gametype, int level) {
&&(mousex < theGame.GetTopX()+cordNextButton.x+cordNextButton.xsize)
&&(mousey > theGame.GetTopY()+cordNextButton.y)&&(mousey < theGame.GetTopY()+cordNextButton.y+cordNextButton.ysize)) {
//Clicked the next button after a stage clear or puzzle
- theGame.nextLevel(SDL_GetTicks());
+ nextLevel(theGame, SDL_GetTicks());
+
}
if (stageButtonStatus != SBdontShow && (mousex > theGame.GetTopX()+cordRetryButton .x)
&&(mousex < theGame.GetTopX()+cordRetryButton.x+cordRetryButton.xsize)