PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/include/ZE_ZAnimation.h

https://github.com/jamesturk/zengine
C Header | 65 lines | 43 code | 13 blank | 9 comment | 0 complexity | 6a7828ca1c1da92ca0551b8aa39b4988 MD5 | raw file
  1. /*******************************************************************************
  2. This file is Part of the ZEngine Library for 2D game development.
  3. Copyright (C) 2002-2004 James Turk
  4. Licensed under a BSD-style license.
  5. The maintainer of this library is James Turk (james@conceptofzero.net)
  6. and the home of this Library is http://www.zengine.sourceforge.net
  7. *******************************************************************************/
  8. #ifndef __ze_zanimation_h__
  9. #define __ze_zanimation_h__
  10. #include "ZE_ZEngine.h"
  11. #include "ZE_ZImage.h"
  12. namespace ZE
  13. {
  14. enum ZAnimType
  15. {
  16. ZANIM_NONE,
  17. ZANIM_ONCE,
  18. ZANIM_LOOP,
  19. ZANIM_REVERSE
  20. };
  21. class ZAnimation
  22. {
  23. protected:
  24. ZEngine *rEngine;
  25. ZImage *rAnimImages;
  26. int rCurFrame;
  27. int rNumFrames;
  28. int rFrameStep;
  29. Uint32 rFrameDelay;
  30. Uint32 rNextFrameTime;
  31. ZAnimType rAnimType;
  32. bool rBackwards;
  33. public:
  34. ZAnimation();
  35. ZAnimation(ZImage *images, int numFrames, Uint32 frameDelay, ZAnimType type, bool backwards=false);
  36. virtual ~ZAnimation();
  37. void Create(ZImage *images, int numFrames, Uint32 frameDelay, ZAnimType type, bool backwards=false);
  38. void SetAnimImages(ZImage *images, int numFrames);
  39. void SetFrameDelay(Uint32 frameDelay);
  40. void SetAnimType(ZAnimType type, bool backwards=false);
  41. void Reset();
  42. void Start();
  43. void Pause();
  44. void SetFrame(int frame);
  45. void Update();
  46. void Draw(float x, float y) const;
  47. bool IsRunning() const;
  48. };
  49. }
  50. #endif //__ze_zanimation_h__