At the beginning of the main loop (before the actual loop), take the current time, call this start_time. Then in each iteration of the loop, take the current time again, call this now. The elapsed time is elapsed_time = now - start_time;. Assuming time is in seconds, then if (elapsed_time >= 120) { ... end game ... } would do the trick.
I presume the game has a "main loop" somewhere.
At the beginning of the main loop (before the actual loop), take the current time, call this
start_time
. Then in each iteration of the loop, take the current time again, call thisnow
. The elapsed time iselapsed_time = now - start_time;
. Assuming time is in seconds, thenif (elapsed_time >= 120) { ... end game ... }
would do the trick.