From dd28f75813a89ebaea13e1245033c81df9cf2b38 Mon Sep 17 00:00:00 2001 From: structix Date: Wed, 24 May 2017 15:47:25 +0200 Subject: [PATCH] Hitscreen gets updated after Player input and before win check --- hangman.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hangman.c b/hangman.c index 881d522..2f3756f 100644 --- a/hangman.c +++ b/hangman.c @@ -104,12 +104,11 @@ void startGame(game_state *gs, hitfeed *hf) { time(&gs->startTime); while (checkWin(gs)) { updateScreen(gs); - printHitFeed(gs, hf); playerInput(gs, hf); + printHitFeed(gs, hf); } } - void quitProgram(void) { endwin(); } @@ -456,9 +455,12 @@ void printHitFeed(game_state *gs, hitfeed *hf) { mvprintw(newMaxy + i, newMaxx, hf->history[i]); } /* Print best score above history feed */ - char message[100]; - sprintf(message, "Best: %s (%i hits)", hf->beststreak, hf->besthit); - mvprintw(newMaxy - 1, newMaxx, message); + if (hf->besthit != 0) { + /* There is a hit. So a best score can be displayed */ + char message[100]; + sprintf(message, "Best: %s (%i hits)", hf->beststreak, hf->besthit); + mvprintw(newMaxy - 1, newMaxx, message); + } } }