Jump to content
  • Advertisement

Archived

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

Discreation

non blocking input

This topic is 5555 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

Is there any way to check for input and also let the program continue running. I currently have cin statements but i dont want the program to wait there for input, it has to continue updating. Ive read about multiple threads but just looking at examples seems over the top for me to currently do. Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
quote:

I'm not so sure on how to do it in console but I think this might work...



Yup it worked I just needed to try it I guess...Is very simple try this...


#include <stdio.h>
#include <conio.h>

int main()
{
while(1)
{
if(kbhit())
{
char x = getch();
if(x == 27) break;
if(x == 'a')printf("A was pressed\n");
//if you want to use arrow keys...

if(x == 77) printf("Right\n");
if(x == 75) printf("Left\n");
if(x == 72) printf("Up\n");
if(x == 80) printf("Down\n");
}

}
return 0;
}



[edited by - FtMonkey on September 24, 2003 2:23:52 PM]

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!