[英]ncurses.h not outputting color change in c
當我的玩家選擇“播放”時,我試圖讓我的游戲中的文本消失。 為此,我想到了將文本的顏色值慢慢更改為黑色。 下面,我選擇了一部分涉及更改顏色值的代碼。 運行程序時,它不會輸出任何內容。 我相信這與在 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;
}
for
循環不會運行。 for(i = 1000; i < 0; --i)
沒有意義,你可能想使用>
而不是<
。
此外,0.2 秒for
將運行 1000 次的for
循環來說太慢了。 在 0.2 秒時,您的循環需要 200 秒才能完成。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.