ncurses.h不输出c的颜色变化

问题描述 投票:0回答:1

我试图让我的玩家选择“玩”时淡出游戏中的文字。为此,我考虑将文本的颜色值缓慢更改为黑色。在下面,我选择了涉及更改颜色值的代码部分。当您运行该程序时,它不会输出任何内容。我相信这与在init_color()函数中使用变量'i'有关。任何帮助将不胜感激

#include <ncurses.h>
#include <unistd.h>

#define SLOW_ROLL usleep(200000)
#define BORDER_INSIDE_Y 40

int main()
{

  int i, row, col;
  initscr(); // Begin ncurses
  cbreak();
  keypad(stdscr, TRUE);
  curs_set(0);
  noecho();
  getmaxyx(stdscr, row, col);
  start_color();
  init_pair(1, COLOR_RED, COLOR_BLACK);
  for(i = 1000; i < 0; --i)
  {
    init_color(COLOR_RED, i, 0, 0);
    attron(COLOR_PAIR(1));
    mvprintw((row / 2) - (BORDER_INSIDE_Y / 2) + 10, (col / 2) - 11, "Welcome to The Game");
    attroff(COLOR_PAIR(1));
    SLOW_ROLL; // usleep function for about .2 seconds
    refresh();
  }

  return 0;
}
c for-loop colors ncurses
1个回答
0
投票

for循环将不会运行。 for(i = 1000; i < 0; --i)没有意义,您可能是想使用>而不是<

© www.soinside.com 2019 - 2024. All rights reserved.