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.
Not sure what you mean... Something like this?
while(Input!=27) //Loop while ESC is not pressed
if(kbhit()) Input=getch(); //Get Keyboard input if a button is pressed
//Whatever code you want...
(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!
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:)).
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.