0

I am building a simple game and I need to set some options, including user timeout to end the game. The following piece of code will clarify what I want:

do {
    //some code
    cin >> ...a char ...;
    if( duration > timeoutLimit)
    {
        cout << "took too long for input ... max imput time reached" << endl;
        break;
    }
}while(...something...);

This is going to work inside de loop and it breaks, if during the user inputs, that may be several, the maximum time allowed is reached. Using clock() I only get the time spent on performed calculations and not the time spent with user input which is what I want.

Pedro R.
  • 87
  • 1
  • 9

1 Answers1

-1

C++ Timer

This may help your issue. I am not an expert on threading but as far as I know, you should do it like in this example.