C game with ncurses - closing window without exiting the program

Question

I'm writing a simple C hangman game, which is my first acquaintance with graphics in C.

In the main function I've put a window menu, using "newwin", "mvwprintw" and "wrefresh". From this menu I'm calling another function for New Game, using new window for it.

I want to have a Quit option from New Game window when Q is pressed, which is leading back to the Menu window.

I've tried with "endwin" for new game window, which doesn't exit the program, but closes the exe and the process should be stopped from the terminal.

How can I close a window and move to another, without deleting the first one?


Show source
| C   | ncurses   2017-01-06 21:01 1 Answers

Answers ( 1 )

  1. 2017-01-06 22:01

    You can hide an existing window by touching the other windows, refreshing those other windows and not referring to the hidden window (including the use of wgetch which would refresh the window).

    To make it reasonably fast, you can combine updates using wnoutrefresh for the touch'd windows and followup with a call to doupdate.

    Further reading:

◀ Go back