-
Keyboard input ?
Prolly not a difficult question, but I'm making a text/ASCII graphic game and there are times where I need to "Cancel input" from the keyboard to allow the user to watch something happen. Where if you hit enter 3 times during it and enter takes you out of the screen at the end you are taken out because I use the getch() command to input. Is there any way to temporarily cease input from the keyboard if using the getch() command? Thanks guys.
-
Hmm
Not sure what you mean... Something like this?
int main()
{
char Input=0;
while(Input!=27) //Loop while ESC is not pressed
{
Input=0;
if(kbhit()) Input=getch(); //Get Keyboard input if a button is pressed
//Whatever code you want...
}
return 0;
}
(I haven't tested the code, it might have some bugs :))
-
Thanks a lot
Hey man, thanks for that advice, it worked! I'm not a very good programmer yet but that command will come in handy =). Thanks again!
-
Another
You can also download another keyboard handler routine from this site: http://shd.cjb.net/
(Press the icon under the speaker)
It's harder to understand, but it lets you press multiple keys at once (great in games:)).
-
stopping input
I was wondering the same thing myself sort of. I need a way to stop all input... Nothing is to get through to the keyboard input buffer thing... And i dont wanna use getchar to stop all but enter... isnt there some ignore_input thing out there... and don't even try that fflush(stdin); thing, that doesnt apply here.