From 8bd852ad8bba6190cb27684604e388620e0e68be Mon Sep 17 00:00:00 2001 From: structix Date: Mon, 22 May 2017 21:30:38 +0200 Subject: [PATCH] Fixed game stats screen #20 --- hangman.c | 23 +++++++++++++++++------ hangman.h | 3 ++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/hangman.c b/hangman.c index 2bcf952..11d7814 100644 --- a/hangman.c +++ b/hangman.c @@ -223,6 +223,7 @@ void drawGuessWord(game_state *gs) { } rows++; } + gs->wordRows = rows; //set the number of rows for clearing the screen later tempstartpos = xcounter = gs->centerx - (gs->wordLength / rows); } @@ -327,14 +328,15 @@ int checkWin(game_state *gs) { void printGameStats(game_state *gs) { //clear(); - int i; + int i, z; double diff; diff = difftime(gs->endTime, gs->startTime); - - for (i = 0; i < gs->maxx; i++) { - mvprintw(gs->centery, i, " "); - mvprintw(gs->centery + 1, i, " "); - } + for (z = 0; z <= gs->wordRows; z++) { //<= takes the last row too + for (i = 0; i < gs->maxx; i++) { + mvprintw(gs->centery + z, i, " "); + //mvprintw(gs->centery + 1, i, " "); + } + } if (gs->moves >= gs->allowedMoves) { mvprintw(gs->centery, gs->centerx - 10, "Game lost. Solution:"); mvprintw(gs->centery + 1, gs->centerx - (gs->wordLength / 2), gs->guessWord); @@ -445,5 +447,14 @@ void drawFigure(game_state *gs, int drawNext) { } + + + +void lala(void) { + int c; + if ((c = getch()) == 10) { + c *= 5; + } +} diff --git a/hangman.h b/hangman.h index d63a810..c2b9e6f 100644 --- a/hangman.h +++ b/hangman.h @@ -5,7 +5,7 @@ /* Defined macros */ #define DEFAULTTRIES 6 -#define MAXWORDLENGTH 100 +#define MAXWORDLENGTH 200 #define ALPHABET 26 #define ALPHABET_NUM 36 #define ANIM_DURATION 1 @@ -28,6 +28,7 @@ typedef struct { char *alphabet; time_t startTime; time_t endTime; + int wordRows; } game_state; typedef struct word {