From 6ba2d3853981812987e3c62e6f2321fd394165c4 Mon Sep 17 00:00:00 2001 From: jathomas2 Date: Mon, 7 Mar 2022 11:57:20 +0100 Subject: [PATCH] Game interface: update nb of round --- Pontu/include/engine/TextLabel.h | 2 +- Pontu/src/view/GameMain.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Pontu/include/engine/TextLabel.h b/Pontu/include/engine/TextLabel.h index 7d5ea98..fbff4b3 100644 --- a/Pontu/include/engine/TextLabel.h +++ b/Pontu/include/engine/TextLabel.h @@ -8,7 +8,7 @@ typedef struct { - char* text; + char* text; SDL_Rect textZone; SDL_Color color; SDL_Texture* texture; diff --git a/Pontu/src/view/GameMain.c b/Pontu/src/view/GameMain.c index a01c769..10ffe6f 100644 --- a/Pontu/src/view/GameMain.c +++ b/Pontu/src/view/GameMain.c @@ -5,6 +5,7 @@ #include "engine/TextureHandler.h" #include "engine/arrayButton.h" #include "engine/arrayTextLabel.h" +#include "engine/TextLabel.h" #include "model/Game.h" #include "model/arrayCoord.h" @@ -105,6 +106,8 @@ void gameView(GeneralState* generalState, SDL_Window* window, SDL_Renderer* rend break; } case InputType_ClickGame: { + int nbRounds= game.nb_rounds; //Store nb_round + if(!array_Coord_Contains(&interactiveCases, inputElement.data.coord, *coordEqual)) { inputProcessor.selectedCase = newCoord(-1,-1); } @@ -127,8 +130,21 @@ void gameView(GeneralState* generalState, SDL_Window* window, SDL_Renderer* rend if (game.phase == GAME_ENDED) { *generalState = GS_EndOfGameMenu; } + if(nbRounds != game.nb_rounds) //Redraw nbTurn if has changed + { + char newNbTurn[20]; + TextLabel nbTurnTextLabel = tabLabel.elems[0]; //First element -> nbTurn label + sprintf(newNbTurn,"Turn : ",game.nb_rounds); //Concatenate Turn with nbTurn + replaceTextAndTextureOfTextLabel(renderer, &nbTurnTextLabel, fontHandler->fonts[FONT_retro], newNbTurn, &nbTurnTextLabel.color); + drawTextLabel(renderer,&nbTurnTextLabel); + //Nouv text label ->nbTurn (replace texture) => replaceTextAndTextureOfTextLabel + //Redraw text label + SDL_RenderPresent(renderer); + } + } + break; } case InputType_Window_Resize: {