commit a1072daf
BlockGame should no longer have any reason for being included instead of compiled seperatly
Changed files
| M | source/code/BlockGame.cpp before |
| M | source/code/BlockGame.hpp before |
| M | source/code/global.hpp before |
| M | source/code/main.cpp before |
| M | source/code/mainVars.inc before |
diff --git a/source/code/BlockGame.cpp b/source/code/BlockGame.cpp
index 69afc9b..61c66de 100644
--- a/source/code/BlockGame.cpp
+++ b/source/code/BlockGame.cpp
@@ -34,11 +34,26 @@ http://blockattack.net
#include "BlockGame.hpp"
#include "puzzlehandler.hpp"
#include "stageclearhandler.hpp"
-#include<boost/lexical_cast.hpp>
+#include <boost/lexical_cast.hpp>
using namespace std;
+static stringstream converter;
+
+//Function to convert numbers to string (2 diget)
+static string itoa2(int num) {
+ converter.str(std::string());
+ converter.clear();
+ if (num<10) {
+ converter << "0";
+ }
+ converter << num;
+ return converter.str();
+}
+
+stageButton stageButtonStatus;
+
static std::stringstream ss; //Used for internal formatting
////////////////////////////////////////////////////////////////////////////////
@@ -1771,7 +1786,7 @@ void BlockGame::Update() {
stop++;
}
if ((puzzleMode)&&(!bGameOver)&&BoardEmpty()) {
- if (!singlePuzzle) {
+ if (!this->singlePuzzle) {
PuzzleSetClear(Level);
stageButtonStatus = SBpuzzleMode;
}
@@ -1919,6 +1934,11 @@ void BlockGame::PerformAction(unsigned int tick, int action, string param) {
break;
};
}
-////////////////////////////////////////////////////////////////////////////////
-///////////////////////// BlockAttack class end ////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////
+
+void BlockGame::setSinglePuzzle(bool singlePuzzle) {
+ this->singlePuzzle = singlePuzzle;
+}
+
+bool BlockGame::isSinglePuzzle() const {
+ return singlePuzzle;
+}
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index fe28bd0..6e1b705 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -49,6 +49,13 @@ http://blockattack.net
#define ACTION_STARTBLOCKS 15
#define ACTION_NOP 16
+enum stageButton {SBdontShow, SBstageClear, SBpuzzleMode};
+
+extern stageButton stageButtonStatus;
+
+//This is the size of the blocks. They are always 50. The internal logic calculates it that way
+const int bsize = 50;
+
////////////////////////////////////////////////////////////////////////////////
//The BloackGame class represents a board, score, time etc. for a single player/
////////////////////////////////////////////////////////////////////////////////
@@ -57,6 +64,7 @@ class BlockGame
private:
int prevTowerHeight;
bool bGarbageFallLeft;
+ bool singlePuzzle = false;
int nextGarbageNumber;
int pushedPixelAt;
@@ -207,6 +215,8 @@ public:
//void SetGameOver();
//Prints "draw" and ends the game
void setDraw();
+ void setSinglePuzzle(bool singlePuzzle);
+ bool isSinglePuzzle() const;
private:
//Test if LineNr is an empty line, returns false otherwise.
bool LineEmpty(int lineNr) const;
@@ -268,7 +278,8 @@ private:
void AI_Move();
//////////////////////////////////////////////////////////////////////////
///////////////////////////// AI ends here! //////////////////////////////
-//////////////////////////////////////////////////////////////////////////
+////////
+//////////////////////////////////////////////////////////////////
void PushLineInternal();
//Updates evrything, if not called nothing happends
diff --git a/source/code/global.hpp b/source/code/global.hpp
index 59e19f4..546b6c9 100644
--- a/source/code/global.hpp
+++ b/source/code/global.hpp
@@ -59,5 +59,6 @@ extern int verboseLevel;
extern Highscore theTopScoresEndless; //Stores highscores for endless
extern Highscore theTopScoresTimeTrial; //Stores highscores for timetrial
+
#endif /* _GLOBAL_HPP */
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 2bb033a..57b31c2 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -227,18 +227,6 @@ static int InitImages(sago::SagoSpriteHolder& holder) {
} //InitImages()
-static stringstream converter;
-
-//Function to convert numbers to string (2 diget)
-static string itoa2(int num) {
- converter.str(std::string());
- converter.clear();
- if (num<10) {
- converter << "0";
- }
- converter << num;
- return converter.str();
-}
/*Draws a image from on a given Surface. Takes source image, destination surface and coordinates*/
void DrawIMG(sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y) {
@@ -1454,12 +1442,12 @@ int PuzzleLevelSelect(int Type) {
string timeString = SPrintStringF(_("Time used: %s"),"-- : --");
if (GetStageTime(selected)>0) {
- timeString = SPrintStringF(_("Time used: %s"), string(itoa(GetStageTime(selected)/1000/60)+" : "+itoa2((GetStageTime(selected)/1000)%60)).c_str() );
+ timeString = SPrintStringF(_("Time used: %d : %02d"), GetStageTime(selected)/1000/60, (GetStageTime(selected)/1000)%60);
}
NFont_Write(screen, 200,200,scoreString.c_str());
NFont_Write(screen, 200,250,timeString.c_str());
- string totalString = (boost::format(_("Total score: %1% in %2%:%3%"))%totalScore%(totalTime/1000/60)%((totalTime/1000)%60)).str(); //"Total score: " +itoa(totalScore) + " in " + itoa(totalTime/1000/60) + " : " + itoa2((totalTime/1000)%60);
+ string totalString = (boost::format(_("Total score: %1% in %2%:%3%"))%totalScore%(totalTime/1000/60)%((totalTime/1000)%60)).str();
NFont_Write(screen, 200,600,totalString.c_str());
}
@@ -1846,6 +1834,7 @@ int main(int argc, char* argv[]) {
if (singlePuzzle) {
LoadPuzzleStages();
theGame.NewPuzzleGame(singlePuzzleNr, SDL_GetTicks());
+ theGame.setSinglePuzzle(true);
}
SDL_RenderClear(screen);
DrawIMG(backgroundImage, screen, 0, 0);
@@ -1943,6 +1932,7 @@ int runGame(int gametype, int level) {
if (singlePuzzle) {
LoadPuzzleStages();
theGame.NewPuzzleGame(singlePuzzleNr, SDL_GetTicks());
+ theGame.setSinglePuzzle(true);
}
//game loop
int done = 0;
diff --git a/source/code/mainVars.inc b/source/code/mainVars.inc
index d8e6a75..7b4d1e6 100644
--- a/source/code/mainVars.inc
+++ b/source/code/mainVars.inc
@@ -26,6 +26,7 @@ http://blockattack.net
#define _MAINVARS_HPP
#include "sago/SagoSprite.hpp"
+#include "BlockGame.hpp"
//main variables and constants
@@ -159,7 +160,6 @@ unsigned long int currentTime; //contains the current time, so we don't cal
static int xsize = 1024;
static int ysize = 768;
-static const int bsize = 50;
//Stores the players names (way to long, but at least no buffer overflows (max length is 16 for display reasons))
std::string player1name;
@@ -205,9 +205,6 @@ control keySettings[3]; //array to hold the controls (default and two custom)
#define KEYMENU_MAXWITH 4
#define KEYMENU_MAXDEPTH 7
-enum stageButton {SBdontShow, SBstageClear, SBpuzzleMode};
-
-static stageButton stageButtonStatus = SBdontShow;
static const int buttonXsize = 120;
static const int buttonYsize = 40;