alrighty im making this game kinda like snake. My problem is that i want to see if there is something in the keyboard buffer or not and not wait for the user to really push a key
f.e
Code:
int running = 1;
while(running)
{
char c=0;
int move;
somefucntionidontknow(c);
switch(c)
{
case 't':
goto(0,-1)
case 'g':
goto(0,1)
case 'f':
goto(-1,0)
case 'h':
goto(0,-1)
default
goto(2,2)
}
sleep(200);
}
goto would remember in what direction the head is and when it gets 2,2 go on in that direction. Problem is , if i use scanf() the computer waits till input if there isnt anything in the keyboard buffer. getch() does the same . I just want to check if a there is something in the buffer , if not go on without waiting. I thought about using threads which seems kinda hard in mingw (im doing this in C only no C++). Any suggestion or is threads my only option???
thank you for you attention if you made it this far