0
私はプリミティブなスネークゲームを構築しようとしています。 関数void Input()
は_kbhit()
と_getch()
を呼び出しますが、問題は、conio.hがlinuxのgccパッケージに含まれていないためにこれらの関数を実装できないことです。 conio
ヘッダーファイルを使用せずに_kbhit()
と_getch()
のタスクを実行する別の方法はありますか?LinuxでC++でkbhit()とgethch()を実装する方法
void Input() // handle controls
{
if(_kbhit()) // boolean positive if key is pressed
{
switch(_getch()) // gets ascii val of key pressed
{
case 'a':
dir = LEFT;
break;
case 'd':
dir = RIGHT;
break;
case 'w':
dir = UP;
break;
case 's':
dir = DOWN;
break;
case 'x':
gameOver = true;
break;
}
}
}
は再び質問を読んで、GetAsyncKeyState()はWinAPIのの一部であり、彼は、Linuxのために何かを望んでいます – CrizerPL