【发布时间】:2014-07-20 08:34:18
【问题描述】:
for (;;)
{
cout << "You are playing for:" << playtime << "seconds." << endl;
cout << "You have " << bytes << " bytes." << endl;
cout << "You are compiling " << bps << " bytes per second." << endl;
cout << "Press a to buy assembler monkey (produces 1 byte per second)/(cost 10 bytes)" << endl;
switch(getch())
{
case 'a': bytes = bytes - 10; bps++; break;
}
bytes = bytes + bps;
playtime++;
Sleep(1000);
system("cls");
}
假设这是我的增量游戏。我想在 1 秒后刷新我的游戏。如何让 getch() 在不停止所有其他内容的情况下等待输入?
【问题讨论】:
-
对于跨平台的东西,您可以在
STDIN_FILENO上select()了解哪些按键正在等待读取。 -
我还是不明白。你能在我的代码中给我看一下吗?
标签: c++ windows input getch conio