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);
我真的希望我不停代码很好的和明确的