kgrsprite.h 2.78 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/****************************************************************************
 *    Copyright 2006  Mauricio Piacentini <mauricio@tabuleiro.com>          *
 *    Copyright 2009  Ian Wadham <iandw.au@gmail.com>                       *
 *                                                                          *
 *    This program is free software; you can redistribute it and/or         *
 *    modify it under the terms of the GNU General Public License as        *
 *    published by the Free Software Foundation; either version 2 of        *
 *    the License, or (at your option) any later version.                   *
 *                                                                          *
 *    This program is distributed in the hope that it will be useful,       *
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *    GNU General Public License for more details.                          *
 *                                                                          *
 *    You should have received a copy of the GNU General Public License     *
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 ****************************************************************************/
18
19
20
21
22
23
24

#ifndef KGRSPRITE_H
#define KGRSPRITE_H

#include <QPixmap>
#include <QList>

25
26
#include <KGameRenderedItem>

27

28
class KGrSprite : public KGameRenderedItem
29
30
{
public:
31
32
    explicit KGrSprite (KGameRenderer * renderer, QString & key,
                        const char type, const int tickTime = 20);
33
    ~KGrSprite();
34

35
36
37
38
    inline char     spriteType      ()        { return m_type; }
    inline QPointF  currentLoc      ()        { return QPointF (m_x, m_y); }
    inline int      currentFrame    ()        { return frame(); }
    inline void     setZ            (qreal z) { setZValue(z); }
39

40
41
42
43
44
    void move           (double x, double y, int frame);
    void animate        (bool missed);
    void setAnimation   (bool repeating, int x, int y, int startFrame,
                         int nFrames, int dx, int dy, int dt,
                         int nFrameChanges);
45
46
    void setCoordinateSystem    (int topLeftX, int topLeftY, int tileSize);
    void changeCoordinateSystem (int topLeftX, int topLeftY, int tileSize);
47
48

private:
49
50
51
    char   m_type;
    char   m_tickTime;
    bool   m_stationary;
52
    bool   m_repeating;
53
54
55
56
57
58
59
60
61
62
63
64
    double m_x;
    double m_y;
    int    m_startFrame;
    int    m_nFrames;
    int    m_frameCtr;
    double m_dx;
    double m_dy;
    int    m_dt;
    int    m_nFrameChanges;
    int    m_ticks;
    double m_frameTicks;
    double m_frameChange;
65
66
67
    double m_oldX;
    double m_oldY;
    int    m_oldFrame;
68
69
70
71

    int    m_topLeftX;
    int    m_topLeftY;
    int    m_tileSize;
72
73
74
};

#endif // KGRSPRITE_H