How do you...
...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"?)
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
------------------------------
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
------------------------------
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement