Hello people,
I am trying to add a small function to allow me to pause the game I am making.
I measure the time elapsed using the following algorithm:
1. USE ""clock_t begin=clock();"" FOR SYSTEM TIME OF GAME BEGINNING.
2. USE ""cout<<(clock()-begin)/CLOCKS_PER_SEC;"" TO DISPLAY TIME ELAPSED IN SECONDS.
Now, if I want to pause, I would want to subtract the 'paused' time from the total time elapsed.Say,
clock_t pause, resume;
{
pause=clock();
.
.
.
resume=clock();
}
Then I would do
cout<<(clock()-begin-(resume-pause))/CLOCKS_PER_SEC;
This, though is what I want, works only once(I can pause only once).
I can use arrays of resume and pause, but it would still limit the number of times I can pause.
What I am looking for is a way to pause any number of times.
Thankyou