0

这是我第一次使用 curses.h。我已经在上面发布了我的代码。当按下右箭头或左箭头时,我需要进行一些函数调用。当我将绘图函数调用添加到我的代码时,按下箭头键时它不会绘制,但在用户按下“q”后程序终止时它会绘制。有任何想法吗?

int main(int argc, char * argv[] )
    {
      setup_curses();  
      c = getch();


      while(1)
      {   
        if (c != ERR)
        {
          move(5,0);
          printw("left arrow key rotates counter-clockwise, right clockwise, space for thrust, q to quit.");
          if (c == KEY_LEFT)
            draw();
          else if (c == KEY_RIGHT) 
            draw();
          else if (c == ' ')
            printw("do something");
          else if (c == 'q')
            break;
          refresh();

        }

        c = getch();

      }



    unset_curses();
    exit(EXIT_SUCCESS);
    }


        void setup_curses()
        {
          initscr();
          cbreak();
          noecho();
          keypad(stdscr, true);
        }

        void unset_curses()
        {
          keypad(stdscr, false);
          nodelay(stdscr, false);
          nocbreak();
          echo();
          endwin();
        }
4

0 回答 0