#### Archived

This topic is now archived and is closed to further replies.

# "proper" timer usage

This topic is 5886 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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...

##### Share on other sites
>>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

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 12
• 10
• 13
• ### Forum Statistics

• Total Topics
632995
• Total Posts
3009774
• ### Who's Online (See full list)

There are no registered users currently online

×