Added winch handler. Alphabet and figure are a buggy
This commit is contained in:
16
hangman.c
16
hangman.c
@@ -13,8 +13,16 @@
|
||||
#include "prng.h"
|
||||
#include <unistd.h> //usleep
|
||||
#include "figures.h"
|
||||
#include <signal.h>
|
||||
|
||||
|
||||
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);
|
||||
|
Reference in New Issue
Block a user