commit 43e3097e
Start drawing the gameboard as an object. Some additional logic is needed for the descriptions to return
Changed files
| M | source/code/BlockGameSdl.hpp before |
| M | source/code/main.cpp before |
| M | source/code/mainVars.inc before |
diff --git a/source/code/BlockGameSdl.hpp b/source/code/BlockGameSdl.hpp
index 03f17ac..bc8eca9 100644
--- a/source/code/BlockGameSdl.hpp
+++ b/source/code/BlockGameSdl.hpp
@@ -62,6 +62,12 @@ public:
setButtonFont(holder, buttonRetry, _("Retry"));
setButtonFont(holder, buttonSkip, _("Skip"));
setButtonFont(holder, stopIntField, "");
+
+ sagoTextSetBlueFont(player_name);
+ sagoTextSetBlueFont(player_time);
+ sagoTextSetBlueFont(player_score);
+ sagoTextSetBlueFont(player_chain);
+ sagoTextSetBlueFont(player_speed);
}
@@ -549,8 +555,87 @@ public:
}
}
}
+
+ std::string strHolder;
+ strHolder = std::to_string(this->GetScore()+this->GetHandicap());
+ player_score.SetText(strHolder);
+ player_score.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()+100);
+ if (this->GetAIenabled()) {
+ player_name.SetText(_("AI"));
+ }
+ else {
+ player_name.SetText(name);
+ }
+ player_name.Draw(globalData.screen, this->GetTopX()+10,this->GetTopY()-34);
+ if (this->isTimeTrial()) {
+ int tid = (int)SDL_GetTicks()-this->GetGameStartedAt();
+ int minutes;
+ int seconds;
+ if (tid>=0) {
+ minutes = (2*60*1000-(abs((int)SDL_GetTicks()-(int)this->GetGameStartedAt())))/60/1000;
+ seconds = ((2*60*1000-(abs((int)SDL_GetTicks()-(int)this->GetGameStartedAt())))%(60*1000))/1000;
+ }
+ else {
+ minutes = ((abs((int)SDL_GetTicks()-(int)this->GetGameStartedAt())))/60/1000;
+ seconds = (((abs((int)SDL_GetTicks()-(int)this->GetGameStartedAt())))%(60*1000))/1000;
+ }
+ if (this->isGameOver()) {
+ minutes=0;
+ }
+ if (this->isGameOver()) {
+ seconds=0;
+ }
+ if (seconds>9) {
+ strHolder = std::to_string(minutes)+":"+std::to_string(seconds);
+ }
+ else {
+ strHolder = std::to_string(minutes)+":0"+std::to_string(seconds);
+ }
+ player_time.SetText(strHolder);
+ }
+ else {
+ int minutes = ((abs((int)SDL_GetTicks()-(int)this->GetGameStartedAt())))/60/1000;
+ int seconds = (((abs((int)SDL_GetTicks()-(int)this->GetGameStartedAt())))%(60*1000))/1000;
+ if (this->isGameOver()) {
+ minutes=(this->GetGameEndedAt()/1000/60)%100;
+ }
+ if (this->isGameOver()) {
+ seconds=(this->GetGameEndedAt()/1000)%60;
+ }
+ if (seconds>9) {
+ strHolder = std::to_string(minutes)+":"+std::to_string(seconds);
+ }
+ else {
+ strHolder = std::to_string(minutes)+":0"+std::to_string(seconds);
+ }
+ player_time.SetText(strHolder);
+ }
+ player_time.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()+150);
+ strHolder = std::to_string(this->GetChains());
+ player_chain.SetText(strHolder);
+ player_chain.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()+200);
+ //drawspeedLevel:
+ strHolder = std::to_string(this->GetSpeedLevel());
+ player_speed.SetText(strHolder);
+ player_speed.Draw(globalData.screen, this->GetTopX()+310,this->GetTopY()+250);
+ if ((this->isStageClear()) &&(this->GetTopY()+700+50*(this->GetStageClearLimit()-this->GetLinesCleared())-this->GetPixels()-1<600+this->GetTopY())) {
+ oldBubleX = this->GetTopX()+280;
+ oldBubleY = this->GetTopY()+650+50*(this->GetStageClearLimit()-this->GetLinesCleared())-this->GetPixels()-1;
+ DrawIMG(globalData.stageBobble,globalData.screen,this->GetTopX()+280,this->GetTopY()+650+50*(this->GetStageClearLimit()-this->GetLinesCleared())-this->GetPixels()-1);
+ }
}
+ sago::SagoTextField player_name;
+ sago::SagoTextField player_time;
+ sago::SagoTextField player_score;
+ sago::SagoTextField player_chain;
+ sago::SagoTextField player_speed;
+
+ //Old Stage Clear Buble
+ int oldBubleX;
+ int oldBubleY;
+
+
private:
int topx, topy;
sago::SagoTextField scoreLabel;
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 2e87d47..57a1468 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -176,17 +176,6 @@ static int InitImages(sago::SagoSpriteHolder& holder) {
globalData.bRetry = holder.GetSprite("b_blank");
globalData.mouse = holder.GetSprite("mouse");
- sagoTextSetBlueFont(player1name);
- sagoTextSetBlueFont(player2name);
- sagoTextSetBlueFont(player1time);
- sagoTextSetBlueFont(player2time);
- sagoTextSetBlueFont(player1score);
- sagoTextSetBlueFont(player2score);
- sagoTextSetBlueFont(player1chain);
- sagoTextSetBlueFont(player2chain);
- sagoTextSetBlueFont(player1speed);
- sagoTextSetBlueFont(player2speed);
-
globalData.cordNextButton.x = 3*bsize+(3*bsize-buttonXsize)/2;
globalData.cordNextButton.y = 10*bsize;
globalData.cordNextButton.xsize = buttonXsize;
@@ -493,7 +482,7 @@ void DrawEverything(int xsize, int ysize,BlockGameSdl* theGame, BlockGameSdl* th
theGame2->DoPaintJob();
std::string strHolder;
strHolder = std::to_string(theGame->GetScore()+theGame->GetHandicap());
- player1score.SetText(strHolder);
+ /*player1score.SetText(strHolder);
player1score.Draw(globalData.screen, theGame->GetTopX()+310,theGame->GetTopY()+100);
if (theGame->GetAIenabled()) {
player1name.SetText(_("AI"));
@@ -560,8 +549,9 @@ void DrawEverything(int xsize, int ysize,BlockGameSdl* theGame, BlockGameSdl* th
oldBubleX = theGame->GetTopX()+280;
oldBubleY = theGame->GetTopY()+650+50*(theGame->GetStageClearLimit()-theGame->GetLinesCleared())-theGame->GetPixels()-1;
DrawIMG(globalData.stageBobble,globalData.screen,theGame->GetTopX()+280,theGame->GetTopY()+650+50*(theGame->GetStageClearLimit()-theGame->GetLinesCleared())-theGame->GetPixels()-1);
- }
- //player1 finnish, player2 start
+ }*/
+ //player1 finnish, player2 start
+#if 0
if (true ) {
/*
*If single player mode (and not VS)
@@ -684,6 +674,7 @@ void DrawEverything(int xsize, int ysize,BlockGameSdl* theGame, BlockGameSdl* th
player2speed.Draw(globalData.screen, theGame2->GetTopX()+310,theGame2->GetTopY()+250);
}
//player2 finnish
+#endif
//draw exit
@@ -1481,12 +1472,12 @@ int runGame(Gametype gametype, int level) {
a.way = 'S';
theGame.DoAction(a);
}
- if ( (event.key.keysym.sym == keySettings[player1keys].left) ) {
+ if ( event.key.keysym.sym == keySettings[player1keys].left ) {
a.action = BlockGameAction::Action::MOVE;
a.way = 'W';
theGame.DoAction(a);
}
- if ( (event.key.keysym.sym == keySettings[player1keys].right) ) {
+ if ( event.key.keysym.sym == keySettings[player1keys].right ) {
a.action = BlockGameAction::Action::MOVE;
a.way = 'E';
theGame.DoAction(a);
@@ -1512,12 +1503,12 @@ int runGame(Gametype gametype, int level) {
a.way = 'S';
theGame2.DoAction(a);
}
- if ( (event.key.keysym.sym == keySettings[player2keys].left) ) {
+ if ( event.key.keysym.sym == keySettings[player2keys].left ) {
a.action = BlockGameAction::Action::MOVE;
a.way = 'W';
theGame2.DoAction(a);
}
- if ( (event.key.keysym.sym == keySettings[player2keys].right) ) {
+ if ( event.key.keysym.sym == keySettings[player2keys].right ) {
a.action = BlockGameAction::Action::MOVE;
a.way = 'E';
theGame2.DoAction(a);
diff --git a/source/code/mainVars.inc b/source/code/mainVars.inc
index 53ff2a7..57143e3 100644
--- a/source/code/mainVars.inc
+++ b/source/code/mainVars.inc
@@ -86,8 +86,7 @@ unsigned long int currentTime; //contains the current time, so we don't cal
bool twoPlayers; //True if two players are playing
-//Old Stage Clear Buble
-static int oldBubleX, oldBubleY;
+
//Allows starting the game with just a single puzzle. Mainly to be able to open a puzzle directly from the level editor
static bool singlePuzzle = false;
@@ -126,16 +125,4 @@ static const int buttonXsize = 120;
static const int buttonYsize = 40;
-static sago::SagoTextField player1name;
-static sago::SagoTextField player2name;
-static sago::SagoTextField player1time;
-static sago::SagoTextField player2time;
-static sago::SagoTextField player1score;
-static sago::SagoTextField player2score;
-static sago::SagoTextField player1chain;
-static sago::SagoTextField player2chain;
-static sago::SagoTextField player1speed;
-static sago::SagoTextField player2speed;
-
-
#endif