i believe it works just cant see it doing..

okay trying to make a count down time for my game and this is what i have so far for the clock

1
2
3
4
5
6
7
8
clock_t previousTime = clock();
{
DrawString("Time: ",450,48,2.2);  
}
int numSecondsPassed = ( clock() - previousTime ) / CLOCKS_PER_SEC;


Are you sure that even one second passes between two calls?
One option is to convert to float (e.g ((float)clock() - previousTime) / CLOCKS_PER_SEC). However clock() function has quite a high granularity and has a limited applicability. If you are under windows, you may use QueryPerformanceCounter/QueryPerformanceFrequency to make much more accurate measures of elapsed time.
clock() updates every ~16ms, I think. Should be more than enough if you want a time in seconds.
CLOCKS_PER_SEC presumably 1000, and DrawString is going to take less than 1s, so numSecondsPassed will always be < 1. Since it's an integer, it will truncate to 0. Various solutions are available, but we need to know what numSecondsPassed is being used for to give good advice.
Topic archived. No new replies allowed.