PageRenderTime 52ms CodeModel.GetById 30ms app.highlight 5ms RepoModel.GetById 15ms app.codeStats 1ms

/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
 5                     Licensed under a BSD-style license.
 6
 7    The maintainer of this library is James Turk (james@conceptofzero.net) 
 8     and the home of this Library is http://www.zengine.sourceforge.net
 9*******************************************************************************/
10
11#ifndef __ze_zanimation_h__
12#define __ze_zanimation_h__
13
14#include "ZE_ZEngine.h"
15#include "ZE_ZImage.h"
16
17namespace ZE
18{
19
20enum ZAnimType
21{
22    ZANIM_NONE,
23    ZANIM_ONCE,
24    ZANIM_LOOP,
25    ZANIM_REVERSE
26};
27
28
29class ZAnimation
30{
31    protected:
32        ZEngine *rEngine;
33        ZImage *rAnimImages;
34        int rCurFrame;
35        int rNumFrames;
36        int rFrameStep;
37        Uint32 rFrameDelay;
38        Uint32 rNextFrameTime;
39        ZAnimType rAnimType;
40        bool rBackwards;
41
42    public:
43        ZAnimation();
44        ZAnimation(ZImage *images, int numFrames, Uint32 frameDelay, ZAnimType type, bool backwards=false);
45        virtual ~ZAnimation();
46
47        void Create(ZImage *images, int numFrames, Uint32 frameDelay, ZAnimType type, bool backwards=false);
48        void SetAnimImages(ZImage *images, int numFrames);
49        void SetFrameDelay(Uint32 frameDelay);
50        void SetAnimType(ZAnimType type, bool backwards=false);
51
52        void Reset();
53        void Start();
54        void Pause();
55        void SetFrame(int frame);
56
57        void Update();
58        void Draw(float x, float y) const;
59
60        bool IsRunning() const;
61};
62
63}
64
65#endif //__ze_zanimation_h__