简体   繁体   中英

C game with ncurses - closing window without exiting the program

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?

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM