home *** CD-ROM | disk | FTP | other *** search
/ Enter 2005 March / ENTER.ISO / files / fwp-0.0.6-win32-installer.exe / Animator.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-01-01  |  1.1 KB  |  63 lines

  1. #ifndef __Animator_h__
  2. #define __Animator_h__
  3.  
  4. #include "File.h"
  5.  
  6. enum animations_e{
  7.     ANIMATION_LEGS_FORWARD = 0,
  8.     ANIMATION_LEGS_BACKWARD,
  9.  
  10.     ANIMATION_WEAPON_RELOAD,
  11.  
  12.     NUM_ANIMATIONS
  13. };
  14.  
  15. typedef struct animation_s{
  16.     int firstKeyframe;
  17.     int lastKeyframe;
  18.     int firstLoopKeyframe;
  19.     int lastLoopKeyframe;
  20.     int numLoopKeyframes;
  21.     int millisPerKeyframe;
  22. }animation_t;
  23.  
  24. class Animator{
  25. public:
  26.     animation_t animations[NUM_ANIMATIONS];
  27.  
  28.     Animator(const char* filename);
  29.     Animator(const Animator& animator);
  30.     ~Animator();
  31.  
  32.     void start();
  33.     void pause();
  34.     void stop();
  35.     float calcCurrentFrame();
  36.     void setCurrentFrame(float newCurrentFrame);
  37.     float getCurrentFrame();
  38.  
  39.     void setCurrentAnimation(int animationId);
  40.     int getCurrentAnimation();
  41.  
  42.     void setLooping(bool looping);
  43.     bool getLooping();
  44.     void setPlayBackwards(bool newPlayBackwards);
  45.     bool getPlayBackwards();
  46.  
  47.     static int getAnimationIdByName(const char* name);
  48.  
  49. protected:
  50.     int currentAnimation;
  51.     float currentFrame;
  52.     bool running;
  53.     bool looping;
  54.     bool playBackwards;
  55.  
  56.     unsigned long lastCalcMillis;
  57.  
  58.  
  59.     bool readFromFile(File* f);
  60. };
  61.  
  62. #endif    /* __Animator_h__ */
  63.