zengine /include/ZE_ZAnimation.h

Language C/C++ Header Lines 66
MD5 Hash 6a7828ca1c1da92ca0551b8aa39b4988 Estimated Cost $993 (why?)
Repository https://github.com/jamesturk/zengine.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
        This file is Part of the ZEngine Library for 2D game development.
                  Copyright (C) 2002-2004 James Turk

                     Licensed under a BSD-style license.

    The maintainer of this library is James Turk (james@conceptofzero.net) 
     and the home of this Library is http://www.zengine.sourceforge.net
*******************************************************************************/

#ifndef __ze_zanimation_h__
#define __ze_zanimation_h__

#include "ZE_ZEngine.h"
#include "ZE_ZImage.h"

namespace ZE
{

enum ZAnimType
{
    ZANIM_NONE,
    ZANIM_ONCE,
    ZANIM_LOOP,
    ZANIM_REVERSE
};


class ZAnimation
{
    protected:
        ZEngine *rEngine;
        ZImage *rAnimImages;
        int rCurFrame;
        int rNumFrames;
        int rFrameStep;
        Uint32 rFrameDelay;
        Uint32 rNextFrameTime;
        ZAnimType rAnimType;
        bool rBackwards;

    public:
        ZAnimation();
        ZAnimation(ZImage *images, int numFrames, Uint32 frameDelay, ZAnimType type, bool backwards=false);
        virtual ~ZAnimation();

        void Create(ZImage *images, int numFrames, Uint32 frameDelay, ZAnimType type, bool backwards=false);
        void SetAnimImages(ZImage *images, int numFrames);
        void SetFrameDelay(Uint32 frameDelay);
        void SetAnimType(ZAnimType type, bool backwards=false);

        void Reset();
        void Start();
        void Pause();
        void SetFrame(int frame);

        void Update();
        void Draw(float x, float y) const;

        bool IsRunning() const;
};

}

#endif //__ze_zanimation_h__
Back to Top