Archived

This topic is now archived and is closed to further replies.

Fractal

How do you...

Recommended Posts

Fractal    122
...get the programme to perform a particular operation WHENEVER a particular key is pressed. This is for my text-based game, if that''s any help. Could I be any more dumber? (What do you mean, "No"?)

Share this post


Link to post
Share on other sites
griffenjam    193
Assuming you are using either a Borland or MS compiler you would enclose your entier program in a while loop and use the function kbhit() to check for input.
like this.

while(1)
{
if(!kbhit())
{
char cKey = getch();
//Respond to input
}
//Do the rest of your game stuff here
}

I hope that helps.
If you are using Dev-C++ (like me right now) then kbhit() doesn''t work, all you have to do in that case is bang your head on youe desk and think about buying another copy of Visual C++.



Jason Mickela
ICQ : 873518
E-Mail: jmickela@pacbell.net
------------------------------
"Evil attacks from all sides
but the greatest evil attacks
from within." Me
------------------------------

Share this post


Link to post
Share on other sites