commit fde1f2dd
One less non-const function in BlockGame and a variable became private
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 61c66de..13bd2f2 100644
--- a/source/code/BlockGame.cpp
+++ b/source/code/BlockGame.cpp
@@ -347,16 +347,6 @@ void BlockGame::NewPuzzleGame(int level, unsigned int ticks) {
}
}
-//Replay the current level
-void BlockGame::retryLevel(unsigned int ticks) {
- if (puzzleMode) {
- NewPuzzleGame(Level, ticks);
- }
- else if (stageClear) {
- NewStageGame(Level, ticks);
- }
-}
-
//Play the next level
void BlockGame::nextLevel(unsigned int ticks) {
if (puzzleMode) {
@@ -1942,3 +1932,17 @@ void BlockGame::setSinglePuzzle(bool singlePuzzle) {
bool BlockGame::isSinglePuzzle() const {
return singlePuzzle;
}
+
+int BlockGame::getLevel() const {
+ return Level;
+}
+
+
+void retryLevel(BlockGame& g, unsigned int ticks) {
+ if (g.isPuzzleMode()) {
+ g.NewPuzzleGame(g.getLevel(), ticks);
+ }
+ else if (g.isStageClear()) {
+ g.NewStageGame(g.getLevel(), ticks);
+ }
+}
\ No newline at end of file
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index 6e1b705..7c446f2 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -80,6 +80,7 @@ private:
bool chainUsed[NUMBEROFCHAINS]; //True if the chain is used
unsigned int nextRandomNumber;
+ int Level; //Only used in stageClear and puzzle (not implemented)
int rand2();
int firstUnusedChain();
@@ -101,7 +102,6 @@ protected:
int pixels;
int MovesLeft;
bool timetrial, stageClear, vsMode, puzzleMode;
- int Level; //Only used in stageClear and puzzle (not implemented)
int stageClearLimit; //stores number of lines user must clear to win
int combo;
int chain;
@@ -177,8 +177,6 @@ public:
//Starts a new stage game, takes level as input!
void NewStageGame(int level, unsigned int ticks);
void NewPuzzleGame(int level, unsigned int ticks);
- //Replay the current level
- void retryLevel(unsigned int ticks);
//Play the next level
void nextLevel(unsigned int ticks);
//Starts new Vs Game (two Player)
@@ -217,6 +215,7 @@ public:
void setDraw();
void setSinglePuzzle(bool singlePuzzle);
bool isSinglePuzzle() const;
+ int getLevel() const;
private:
//Test if LineNr is an empty line, returns false otherwise.
bool LineEmpty(int lineNr) const;
@@ -286,8 +285,8 @@ private:
void Update();
void UpdateInternal(unsigned int newtick);
};
-////////////////////////////////////////////////////////////////////////////////
-///////////////////////// BlockAttack class end ////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
+
+//Replay the current level
+void retryLevel(BlockGame& g, unsigned int ticks);
#endif
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 5d6770e..b6c649c 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -790,7 +790,7 @@ public:
if (puzzleMode && stageButtonStatus == SBpuzzleMode) {
DrawImgBoard(bRetry, cordRetryButton.x, cordRetryButton.y);
PrintTextCenteredBoard(cordRetryButton.x, cordRetryButton.y, _("Retry"));
- if (Level<PuzzleGetNumberOfPuzzles()-1) {
+ if (getLevel()<PuzzleGetNumberOfPuzzles()-1) {
if (hasWonTheGame) {
DrawImgBoard(bNext,cordNextButton.x, cordNextButton.y);
PrintTextCenteredBoard(cordNextButton.x, cordNextButton.y, _("Next"));
@@ -808,7 +808,7 @@ public:
if (stageClear && stageButtonStatus == SBstageClear) {
DrawImgBoard(bRetry, cordRetryButton.x, cordRetryButton.y);
PrintTextCenteredBoard(cordRetryButton.x, cordRetryButton.y, _("Retry"));
- if (Level<50-1) {
+ if (getLevel()<50-1) {
if (hasWonTheGame) {
DrawImgBoard(bNext,cordNextButton.x, cordNextButton.y);
PrintTextCenteredBoard(cordNextButton.x, cordNextButton.y, _("Next"));
@@ -2291,7 +2291,7 @@ int runGame(int gametype, int level) {
&&(mousex < theGame.GetTopX()+cordRetryButton.x+cordRetryButton.xsize)
&&(mousey > theGame.GetTopY()+cordRetryButton.y)&&(mousey < theGame.GetTopY()+cordRetryButton.y+cordRetryButton.ysize)) {
//Clicked the retry button
- theGame.retryLevel(SDL_GetTicks());
+ retryLevel(theGame, SDL_GetTicks());
}