void SinglePlayer(void) { /* 啟動鍵盤控制 */ initializeKeyInput(); char ch='0'; winTimes=0; //Left loseTimes=0; count = 0; int pick = -1; int initime=clock(); int time; while(winTimes<3 && loseTimes<3) { clearScreen(); if(turn == 0) { ch = getKeyEventVirtual(); switch(ch) { case 0x58: //左方拍桌 check(pick,initime); initime = clock(); break; case 0x5A: if(count==pick) { Loser(); } else getNewCard(); initime = clock(); break; } } else { if(waitForKeyDown(3.0)) { ch = getKeyEventVirtual(); if(ch == 0x58){ check(pick,initime); initime = clock(); } } else //if(tick > WAIT_TIME) { getNewCard(); initime = clock(); } } } if(loseTimes==3) gameover(); showingPlane =2; }
void check(int pick,int initime) { int time = initime - clock(); if(count==pick) { if(time<WAIT_TIME) { winTimes++; changeTurn(); } else { Loser(); } } else { Loser(); } }
int main(int argc, char const *argv[]) { initscr(); raw(); noecho(); curs_set(0); keypad(stdscr,TRUE); getmaxyx(stdscr,row,col); srand(time(NULL)); if (gameinit()) Winner(); else Loser(); getch(); endwin(); return 0; }