I'm trying to build a primitive snake game.
The function void Input()
calls _kbhit()
and _getch()
But the problem is that I can't implement these function 'cause conio.h isn't included in the gcc package in linux. Is there an alternative way to accomplish the tasks of _kbhit()
and _getch()
without using conio
header file ?
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;
}
}
}