Jump to content
  • Advertisement

Archived

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

Fractal

How do you...

This topic is 6094 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

...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
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!