简体   繁体   English

带有ncurses的C游戏-关闭窗口而不退出程序

[英]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. 我正在编写一个简单的C hangman游戏,这是我第一次接触C语言中的图形。

In the main function I've put a window menu, using "newwin", "mvwprintw" and "wrefresh". 在主要功能中,我使用“ newwin”,“ mvwprintw”和“ 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. 我想在按Q时从New Game窗口中有一个Quit选项,该选项又回到Menu窗口。

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. 我尝试使用“ endwin”来创建新游戏窗口,该窗口不会退出程序,而是会关闭exe,并且应从终端停止进程。

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). 您可以通过触摸其他窗口,刷新其他窗口而不引用隐藏的窗口来隐藏现有窗口(包括使用wgetch刷新窗口)。

To make it reasonably fast, you can combine updates using wnoutrefresh for the touch'd windows and followup with a call to doupdate . 为了使更新速度合理,您可以将wnoutrefresh用于触摸屏的更新结合在一起,并通过对doupdate的调用进行doupdate

Further reading: 进一步阅读:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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