0
你好,我正在用C創建一個遊戲。我想在那裏每隔0.1秒打印一幀圖片。在此期間,用戶可能會或可能不會使用getch()輸入。等待最多X次輸入,然後繼續執行程序?
我該如何編寫這樣的程序?下面我可以提供給你們一起工作。
do{
usleep(100000); // simple 100 mili second delay
if (getch()==32) (ASCII for a space) // may or may not be inputed in 0.1 second timeframe.
playerJumps;
// even if user inputs early, I still want game printed exactly every 0.1 sec not sooner/later.
printGame;
}while(notDead);
我真的希望我不停代碼很好的和明確的