Limiting time on user input.

I am currently working on a text based game( console app ) written in c++. For one part of the game I would like to display a letter to the user then give them a certain amount of time to press that character. If the time expires before the user has pressed anything or the correct key(1 chance only) it will say "Failed!!". I'm not looking for the exact solution here, but if someone could point me in the right direction I'm sure I could figure this out.

Thanks for your time,

Last edited on
Try GetTickCount() since u want the user to still be able to do things. Store the first value, then keep calling it in ur loop (the loop that the user is in while figuring the puzzle out) and compare the 2 values until the elapsed time u want (in miliseconds).

Last edited on
How about Timer class from some third party, or you create yourself for you using thread..

Simple logic is ,
Just start a thread with your defined ms, and check in it's run condition when time's up kill thread and show the message, If before times run out, just kill the thread.

How abt that ? hamm cowBoy ?
Topic archived. No new replies allowed.