home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 06 General Architectures / 04 Christian / gametime.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-16  |  406 b   |  30 lines

  1.  
  2.  
  3. #include "gametime.h"
  4. #include <stdio.h>
  5.  
  6. double GameTime::dt = 0.016f;
  7.  
  8. GameTime::GameTime ()
  9. {
  10. }
  11.  
  12. void GameTime::start ()
  13. {
  14.     m_startTime = clock();
  15. }
  16.  
  17. void GameTime::end ()
  18. {
  19.     dt = 0.0f;
  20.  
  21.     // force dt to be slow for our text game
  22.     while ( dt < 0.3f )
  23.     {
  24.         m_endTime = clock();
  25.  
  26.         dt = (double)(m_endTime - m_startTime) / CLOCKS_PER_SEC;
  27.     }
  28. }
  29.  
  30.