diff --git a/hangman.c b/hangman.c index 3f1e175..8b3838d 100644 --- a/hangman.c +++ b/hangman.c @@ -13,8 +13,16 @@ #include "prng.h" #include //usleep #include "figures.h" +#include +void handle_winch(int sig) { + /* This function handles the console resizing */ + endwin(); + clear(); + refresh(); +} + int main(int argc, char **argv) { const char *short_options = "w:hf:ct"; @@ -35,6 +43,13 @@ int main(int argc, char **argv) { /* Initialization */ initscr(); atexit(quitProgram); + + //Windows resize handler + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); + sa.sa_handler = handle_winch; + sigaction(SIGWINCH, &sa, NULL); + start_color(); //Enables multi color mode /* Initialize custom color pairs */ @@ -105,6 +120,7 @@ void startGame(game_state *gs, hitfeed *hf) { noecho(); /* Don't show the player input */ time(&gs->startTime); while (checkWin(gs)) { + initCoordinates(gs); //Necessary for window resizing updateScreen(gs); playerInput(gs, hf); printHitFeed(gs, hf);