"proper" timer usage

Started by
0 comments, last by Iolo 21 years, 7 months ago
Okay I''m not too sure how to title this one. My goal is to create a class which I can use for putting my game in "demo mode"...ie. The game begins in a TITLE state, which simply displays the titles to my game. Then after a pre-determined time span, it automatically switches over to the HIGHSCORE state to display the high scores. These state changes can only be halted by the user hitting "ESC" to open the main menu.. Now in my "Update" method (which is obviously being called each frame) I''m passing in the difference between the time it takes to process a frame..
  
dwCurrentTime = timeGetTime()<br>
::UpdateGame(dwCurrentTime - dwLastTime)<br>
dwLastTime = dwCurrentTime;
  
but what would I use to maintain a "10 second" time frame between mode switches? ie. it''s in TITLE state for 10 seconds, then HIGHSCORE state for another 10 seconds, etc.. If I use the system clock, then the time will go quicker than on a slower CPU. I guess long question short, how can I use the variable I pass into the UpdateGame method within the calculations to ensure I''m maintaining a "10 second"-ish count?? Did that make any sense? I really appreciate any advice...
Advertisement
>>If I use the system clock, then the time will go quicker than on a slower CPU.<<

i hope not

static int start_of_title_display = clock() (or any timer function u want)

if ( clock() > (start_of_title_display + 10000))
change over to highscore

a lot of timers work in ms thus 1000 == 1 second

http://uk.geocities.com/sloppyturds/gotterdammerung.html

This topic is closed to new replies.

Advertisement