Skip to main content
GameDev.net gamedev.net
🔒 Locked

using DXUtil_Timer for state changes??

Started by Iolo Jan 22, 2003 at 1:50 PM 0 replies 1.7k views
Original Post
Iolo
Iolo
Hi all, Just trying to get my app working so that if the user doesn''t touch the ESC key, the game automatically switches between displaying the game titles, and displaying the high scores.. ie.
  
float fTime = DXUtil_Timer(TIMER_GETAPPTIME);
switch(eState){
  case TITLE_STATE:
     if((int)fTime % 3 == 0){
        //3 seconds have elapsed, go to the high scores

        eState = HIGHSCORE_STATE;
      }
      break;
   case HIGHSCORE_STATE:
      if((int)fTime % 3 == 0){
       //3 seconds have elapsed go to the title state

       eState = TITLE_STATE;
      }
      break;
  }
  
However it just doesn''t work. I get super fast state changes between the two (ie. it flickers between TITLE and HIGHSCORE state at a high speed).. How have others approached this?
MichaelT
MichaelT
I would suggest you use DWORD timeGetTime(VOID); instead.
the return value is in milliseconds and should suit your needs
better than a half decent DXUtil_Timer function. If you want better resolution (and if your machine supports it) you can use QueryPerformanceFrequency()instead which returns cpu cycles instead. It should be supported by almost all machines today.
MS says it returns high-resolution performance counter but they basically just poll the cpu counter from the cpu. It won''t wrap for the next 6000 years or so either so you should do fine with that.

____________________________________________________________
Try RealityRift at www.planetrift.com
No no no no! :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.