View Single Post
Old 03-23-2003, 10:08 AM   #6 (permalink)
Mr.Anderson
Registered User
 
Mr.Anderson's Avatar
 
Join Date: Mar 2003
Location: In a van, down by the river.
Posts: 24
Mr.Anderson is on a distinguished road
Send a message via AIM to Mr.Anderson Send a message via Yahoo to Mr.Anderson
Oohh... that's going to hurt.

Quote:
Originally posted by Gorbash9k
I should have told my problem more indepth, I needed a way for the game to keep running while the user is inputting his command. I finally though of a way though, I'm going to set a timer of some small amount, where if the user doesnt input when the timer runs out, the computer will just put in a NULL response and continue on. My problem now is how to set a timer.

Anyways this is the program that my friend sent me.

/////////////////////////////////////////////////////////////////////////////////

#include <conio.h>

#include <iostream>
using std::cout;
using std::endl;

int main()
{
char tmp;

system("cls");

cout << "Hit a key, please ('q' to quit)." << endl;

do
{
while(!_kbhit());
tmp = _getch();
cout << tmp;
} while (tmp != 'q');

cout << endl << endl;

system("pause");
return 0;
}
/////////////////////////////////////////////////////////////////////////////////
I might just be a pompus, rotund, and arrogant pile of unnecessary carbon, but it sounds like you might need to do some multi-threading. Haveing the timer count down and getting commands at the EXACT same time? I would think so.
Then again, I'm a n00b.

Multi threading ... quite frankly, I hate the stuff. (Probably because I've never been able to do it.)

I wish I could have been more help. Sorry if I've said anything stupid.

THen again, if you just want to have the user enter something AND THEN update the timer, Pussnuts's idea is a pretty good one.

Have a nice day.

-- Jo
Mr.Anderson is offline   Reply With Quote