[英]Am I using the getch() function from the ncurses library incorrectly?
[英]Am I using ncurses correctly for a Vector?
我编写了一个小游戏,它应该可以在控制台上玩。 为此,我使用ncurses进行编译,但是当我启动游戏时,控制台上没有任何显示。 gamearea保存在2d Vector中,并且值在此Vector中,我使用正常printf且没有ncurses对其进行了检查,一切都很好,但是如果我要使用ncurses,则不会在控制台上打印任何内容。
for (auto const& i : gamearea) {
for (auto const& j : i){
// Wall
if (j == '#') {
// printf("#\n");
attron(5);
mvprintw(_height, _width, " ");
attroff(5);
}
这是来自Function的一段代码,如果使用几乎相同的代码循环,则在此Function中还有6条代码。 gamearea是我的2d Vector,_height和_width是变量,它们表示空间应该多大。 空格替换#。
我想知道的是,我在哪里使用ncurses函数错误? 我已经在其他功能中将终端与所有需要的都初始化了:
void Play::initTerminal() {
initscr();
cbreak();
noecho();
curs_set(false);
nodelay(stdscr, true);
keypad(stdscr, true);
start_color();
use_default_colors();
init_pair(1, COLOR_BLACK, COLOR_BLACK);
init_pair(2, COLOR_GREEN, COLOR_GREEN);
init_pair(3, COLOR_BLUE, COLOR_BLUE);
init_pair(4, COLOR_YELLOW, COLOR_YELLOW);
init_pair(5, COLOR_WHITE, COLOR_WHITE);
init_pair(6, COLOR_RED, COLOR_RED);
init_pair(7, COLOR_CYAN, COLOR_CYAN);
}
也许我在此功能中做错了。 我以前只使用过ncurses一次,在那儿我使用过printf,但是这次我想使用ncurses中的函数。 我在这里没有找到类似的东西。
您的颜色对有误
init_pair (5, COLOR_WHITE, COLOR_WHITE)
将在白色背景上写白色字符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.