From 588702418fb14c36bee9c2ca5c0164a65f889ed8 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Fri, 29 Mar 2019 17:51:43 -0400 Subject: Add king win face --- freecell.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/freecell.c b/freecell.c index ea7b8b6..2d1b97c 100644 --- a/freecell.c +++ b/freecell.c @@ -69,6 +69,13 @@ static void gameDeal(void) { kingFace = Cards_KingRight; } +static bool gameWin(void) { + for (uint i = Foundation1; i <= Foundation4; ++i) { + if (stacks[i].len != 13) return false; + } + return true; +} + static bool gameFind(uint *stack, uint *index, Card card) { for (*stack = 0; *stack < StacksLen; ++*stack) { for (*index = 0; *index < stacks[*stack].len; ++*index) { @@ -156,13 +163,17 @@ enum { TableauX = StackMarginX, TableauY = CellY + CardHeight + StackMarginY, - FanDownDeltaY = 17, + KingWinMarginX = 10, + KingWinMarginY = 10, + KingWinX = KingWinMarginX, + KingWinY = CellY + CardHeight + KingWinMarginY, + KingWinWidth = 320, + KingWinHeight = 320, + WindowWidth = 8 * CardWidth + 9 * StackMarginX + 1, - WindowHeight = TableauY + CardHeight - + 13 * FanDownDeltaY - + StackMarginY, + WindowHeight = KingWinY + KingWinHeight + KingWinMarginY, }; static const struct Style FanDown = { 1, 0, 0, 0, FanDownDeltaY }; @@ -316,11 +327,16 @@ static void renderOutlines(void) { static void renderKing(SDL_Texture *textures[]) { SDL_Rect box = { KingX, KingY, KingWidth, KingHeight }; renderOutline(box, true); - SDL_Rect king = { - KingX + KingPadX, KingY + KingPadY, - Cards_KingWidth, Cards_KingHeight, - }; - SDL_RenderCopy(render, textures[kingFace], NULL, &king); + if (gameWin()) { + SDL_Rect king = { KingWinX, KingWinY, KingWinWidth, KingWinHeight }; + SDL_RenderCopy(render, textures[Cards_KingWin], NULL, &king); + } else { + SDL_Rect king = { + KingX + KingPadX, KingY + KingPadY, + Cards_KingWidth, Cards_KingHeight, + }; + SDL_RenderCopy(render, textures[kingFace], NULL, &king); + } } static void renderList(SDL_Texture *textures[], const struct List *list) { -- cgit 1.4.1