0

ncurses.h を使用してゲームのメニューを作成しています。この部分では、点滅するテキストを画面に表示し、ユーザーがいずれかのキーを押した場合にのみそのループを終了します。conio.h では、これを使用しました (完璧ではありませんでした):

void start()
{
    int i;

    for (i = 0; i < 10; i++)
    {
        gotoxy(32, 18 - i);
        printf("1024");
        Sleep(200);
        clrscr();
    }

    gotoxy(32, 8);
    printf("1024");
    gotoxy (35, 18);

    while (!kbhit())            

    {
        textcolor(15);          
        gotoxy (15, 15);
        printf("Press any key to continue...");

        if (kbhit() != 0)                                   

        Sleep(1000);
        textcolor(0);           
        gotoxy (15, 15);
        printf("Aperte qualquer tecla para continuar...");

        if (kbhit() != 0)
            break;

        Sleep(500);

        if (kbhit() != 0)
            break;

    }

    textcolor(15);
    fflush(stdin);
    clrscr();

}

ncurses.h で同じことをしようとしていますが、getch() はユーザー入力を待っているように見えるため、実行を「一時停止」します。

void start()
{
    int i, ch = 0;

    for (i = 0; i < 10; i++)
    {
        attron(COLOR_PAIR(2));
        move(18 - i, 32);
        printw("1024");
        refresh();
        usleep(200 * 1000);
        clear();
        refresh();
    }

    move(18, 35);

    while (1)
    {
        if (getch() != 0)
            break;

        attron(COLOR_PAIR(2));
        move(15, 15);

        printw("Aperte qualquer tecla para continuar...");
        refresh();

        usleep(1000 * 1000);
        clear();
        refresh();
        move(15, 15);
        printw("Aperte qualquer tecla para continuar...");

        usleep(500 * 1000);

    }

    attroff(COLOR_PAIR(2));
    system("clear");

}

ソリューション?ありがとう!

4

1 に答える 1