diff --git a/Game/data/sprites/blockattack1.sprite b/Game/data/sprites/blockattack1.sprite index ddf9e71..cff6284 100644 --- a/Game/data/sprites/blockattack1.sprite +++ b/Game/data/sprites/blockattack1.sprite @@ -387,24 +387,6 @@ "number_of_frames" : 1, "frame_time" : 1 }, -"i_draw" : { - "texture" : "i_draw", - "topx" : 0, - "topy" : 0, - "height" : 100, - "width" : 300, - "number_of_frames" : 1, - "frame_time" : 1 -}, -"i_game_over" : { - "texture" : "i_game_over", - "topx" : 0, - "topy" : 0, - "height" : 100, - "width" : 300, - "number_of_frames" : 1, - "frame_time" : 1 -}, "i_level_check_box_marked" : { "texture" : "i_level_check_box_marked", "topx" : 0, @@ -432,15 +414,6 @@ "number_of_frames" : 1, "frame_time" : 1 }, -"i_loser" : { - "texture" : "i_loser", - "topx" : 0, - "topy" : 0, - "height" : 100, - "width" : 300, - "number_of_frames" : 1, - "frame_time" : 1 -}, "i_stage_clear_limit" : { "texture" : "i_stage_clear_limit", "topx" : 0, @@ -450,15 +423,6 @@ "number_of_frames" : 1, "frame_time" : 1 }, -"i_winner" : { - "texture" : "i_winner", - "topx" : 0, - "topy" : 0, - "height" : 100, - "width" : 300, - "number_of_frames" : 1, - "frame_time" : 1 -}, "menu_marked" : { "texture" : "menu_marked", "topx" : 0, diff --git a/Game/data/textures/i_draw.png b/Game/data/textures/i_draw.png deleted file mode 100755 index 3881038..0000000 Binary files a/Game/data/textures/i_draw.png and /dev/null differ diff --git a/Game/data/textures/i_game_over.png b/Game/data/textures/i_game_over.png deleted file mode 100755 index 0dd2133..0000000 Binary files a/Game/data/textures/i_game_over.png and /dev/null differ diff --git a/Game/data/textures/i_loser.png b/Game/data/textures/i_loser.png deleted file mode 100755 index d84fd68..0000000 Binary files a/Game/data/textures/i_loser.png and /dev/null differ diff --git a/Game/data/textures/i_winner.png b/Game/data/textures/i_winner.png deleted file mode 100755 index e6b012e..0000000 Binary files a/Game/data/textures/i_winner.png and /dev/null differ diff --git a/source/code/BlockGameSdl.inc b/source/code/BlockGameSdl.inc index cb551ed..d42161e 100644 --- a/source/code/BlockGameSdl.inc +++ b/source/code/BlockGameSdl.inc @@ -24,6 +24,7 @@ https://blockattack.net #include "BlockGame.hpp" #include "global.hpp" #include "sago/SagoTextField.hpp" +#include "mainVars.inc" static void setScoreboardFont(const sago::SagoDataHolder* holder, sago::SagoTextField& field, const char* text){ field.SetHolder(holder); @@ -436,14 +437,14 @@ public: if (bGameOver) { if (hasWonTheGame) { - DrawImgBoard(iWinner, 0, 5*bsize); + tbWinner.Draw(globalData.screen, topx+150, topy+200, sago::SagoTextField::Alignment::center); } else { if (bDraw) { - DrawImgBoard(iDraw, 0, 5*bsize); + tbDraw.Draw(globalData.screen, topx+150, topy+200, sago::SagoTextField::Alignment::center); } else { - DrawImgBoard(iGameOver, 0, 5*bsize); + tbGameOver.Draw(globalData.screen, topx+150, topy+200, sago::SagoTextField::Alignment::center); } } } diff --git a/source/code/main.cpp b/source/code/main.cpp index 25fe404..50b7d71 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -111,6 +111,16 @@ static void PhysFsCreateFolders() { PHYSFS_mkdir("puzzles"); } +static void setGameOverFont(const sago::SagoDataHolder* holder, sago::SagoTextBox& field, const char* text) { + field.SetHolder(holder); + field.SetFont("freeserif"); + field.SetColor({0,0,255,255}); + field.SetFontSize(60); + field.SetOutline(3, {192,192,255,255}); + field.SetMaxWidth(280); + field.SetText(text); +} + //Load all image files to memory static int InitImages(sago::SagoSpriteHolder& holder) { bricks[0] = holder.GetSprite("block_blue"); @@ -144,10 +154,9 @@ static int InitImages(sago::SagoSpriteHolder& holder) { counter[0] = holder.GetSprite("counter_1"); counter[1] = holder.GetSprite("counter_2"); counter[2] = holder.GetSprite("counter_3"); - iGameOver = holder.GetSprite("i_game_over"); - iWinner = holder.GetSprite("i_winner"); - iDraw = holder.GetSprite("i_draw"); - iLoser = holder.GetSprite("i_loser"); + setGameOverFont(&holder.GetDataHolder(),tbGameOver, _("GAME OVER")); + setGameOverFont(&holder.GetDataHolder(),tbWinner, _("WINNER")); + setGameOverFont(&holder.GetDataHolder(),tbDraw, _("DRAW")); iChainFrame = holder.GetSprite("chain_frame"); globalData.iLevelCheck = holder.GetSprite("i_level_check"); globalData.iLevelCheckBox = holder.GetSprite("i_level_check_box"); diff --git a/source/code/mainVars.inc b/source/code/mainVars.inc index f30b3c0..bb438f5 100644 --- a/source/code/mainVars.inc +++ b/source/code/mainVars.inc @@ -28,6 +28,7 @@ http://blockattack.net #include "sago/SagoSprite.hpp" #include "BlockGame.hpp" #include "sago/SagoTextField.hpp" +#include "sago/SagoTextBox.hpp" //main variables and constants @@ -57,10 +58,9 @@ static sago::SagoSprite bForward; //The "forward" button static sago::SagoSprite blackLine; //The seperator in stage clear static sago::SagoSprite stageBobble; //The bobble instage clear SDL_Renderer *screen; //The whole screen; -static sago::SagoSprite iGameOver; //The gameOver image -static sago::SagoSprite iWinner; //the "winner" image -static sago::SagoSprite iDraw; //the "draw" image -static sago::SagoSprite iLoser; //the "loser" image +static sago::SagoTextBox tbGameOver; +static sago::SagoTextBox tbWinner; +static sago::SagoTextBox tbDraw; static sago::SagoSprite iChainFrame; //Animations: static sago::SagoSprite cursor; //The animated cursor diff --git a/source/code/sago/SagoTextBox.cpp b/source/code/sago/SagoTextBox.cpp index 8a531bf..2f98a20 100644 --- a/source/code/sago/SagoTextBox.cpp +++ b/source/code/sago/SagoTextBox.cpp @@ -178,14 +178,14 @@ void SagoTextBox::UpdateCache() { data->renderedText = data->text; } -void SagoTextBox::Draw(SDL_Renderer* target, int x, int y) { +void SagoTextBox::Draw(SDL_Renderer* target, int x, int y, SagoTextField::Alignment alignment ) { if (data->text != data->renderedText) { UpdateCache(); } TTF_Font *font = data->tex->getFontPtr(data->fontName, data->fontSize); int lineSkip = TTF_FontLineSkip(font); for (size_t i = 0; i < data->lines.size(); ++i) { - data->lines[i].Draw(target, x, y+i*lineSkip); + data->lines[i].Draw(target, x, y+i*lineSkip, alignment); } } diff --git a/source/code/sago/SagoTextBox.hpp b/source/code/sago/SagoTextBox.hpp index 906fae2..e0b7096 100644 --- a/source/code/sago/SagoTextBox.hpp +++ b/source/code/sago/SagoTextBox.hpp @@ -56,7 +56,7 @@ public: */ void SetMaxWidth(int width); const std::string& GetText() const; - void Draw(SDL_Renderer* target, int x, int y); + void Draw(SDL_Renderer* target, int x, int y, SagoTextField::Alignment alignment = SagoTextField::Alignment::left); void UpdateCache(); private: void AppendLineToCache(const std::string& text);