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

  1.  
  2. #include "anim.h"
  3. #include "gametime.h"
  4. #include <stdio.h>
  5.  
  6. Anim::Anim ( float time, bool loop )
  7. {
  8.     m_time  = time;
  9.     m_clock = 0.0f;
  10.     m_loop  = loop;
  11. }
  12.  
  13. void Anim::start ()
  14. {
  15.     m_clock = 0.0f;
  16. }
  17.  
  18. bool Anim::update ()
  19. {
  20.     m_clock += GameTime::dt;
  21.  
  22.     if ( m_loop && m_clock >= m_time )
  23.         m_clock = 0.0f;
  24.  
  25.     return done();
  26. }
  27.  
  28. bool Anim::done ()
  29. {
  30.     if ( m_clock >= m_time && ! m_loop )
  31.     {
  32.         return true;
  33.     }
  34.     else
  35.         return false;
  36. }