1/*
2 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef KAPMANITEM_H
19#define KAPMANITEM_H
20
21#include "characteritem.h"
22#include "kapman.h"
23
24#include <QTimeLine>
25
26/**
27 * @brief This class manage the display of the Kapman.
28 */
29class KapmanItem : public CharacterItem {
30
31 Q_OBJECT
32
33 private:
34
35 /** Number of frames to animate the KapmanItem */
36 static const int NB_FRAMES;
37
38 /** Animation update interval */
39 static const int ANIM_LOW_SPEED;
40 static const int ANIM_MEDIUM_SPEED;
41 static const int ANIM_HIGH_SPEED;
42
43 /** Timer used to animate the KapmanItem */
44 QTimeLine * m_animationTimer;
45
46 /** Rotation flag set by theme */
47 bool m_rotationFlag;
48
49 public:
50
51 /**
52 * Creates a new KapmanItem instance.
53 * @param p_model the Kapman model
54 */
55 KapmanItem(Kapman* p_model);
56
57 /**
58 * Deletes the KapmanItem instance.
59 */
60 ~KapmanItem();
61
62 public slots:
63
64 /**
65 * Rotates the image function of the Kapman direction.
66 */
67 void updateDirection();
68
69 /**
70 * Manages the collisions with any Element.
71 */
72 void manageCollision();
73
74 /**
75 * Updates the KapmanItem coordinates.
76 * @param p_x the new x-coordinate
77 * @param p_y the new y-coordinate
78 */
79 void update(qreal p_x, qreal p_y);
80
81 /**
82 * Starts the KapmanItem animation.
83 */
84 void startAnim();
85
86 /**
87 * Pauses the KapmanItem animation.
88 */
89 void pauseAnim();
90
91 /**
92 * Resumes the KapmanItem animation.
93 */
94 void resumeAnim();
95
96 /**
97 * Stops the KapmanItem animation.
98 */
99 void stopAnim();
100
101 /**
102 * Sets the given frame to the KapmanItem.
103 * @param p_frame the frame to set
104 */
105 void setFrame(const int p_frame);
106
107 /**
108 * Implements the CharacterItem method.
109 */
110 void startBlinking();
111
112 /**
113 * Implements the CharacterItem method.
114 */
115 void blink();
116
117 /**
118 * Set if the KapmanItem should be rotated (set by theme flag RotateKapman).
119 * @param 0 or 1
120 */
121 void setRotationFlag(bool rotate) { m_rotationFlag=rotate; }
122
123};
124
125#endif
126
127