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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
/*
* Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
*
* 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/>.
*/
#ifndef KAPMANITEM_H
#define KAPMANITEM_H
#include "characteritem.h"
#include "kapman.h"
#include <QTimeLine>
/**
* @brief This class manage the display of the Kapman.
*/
class KapmanItem : public CharacterItem
{
Q_OBJECT
private:
/** Number of frames to animate the KapmanItem */
static const int NB_FRAMES;
/** Animation update interval */
static const int ANIM_LOW_SPEED;
static const int ANIM_MEDIUM_SPEED;
static const int ANIM_HIGH_SPEED;
/** Timer used to animate the KapmanItem */
QTimeLine *m_animationTimer;
/** Rotation flag set by theme */
bool m_rotationFlag;
public:
/**
* Creates a new KapmanItem instance.
* @param p_model the Kapman model
*/
explicit KapmanItem(Kapman *p_model);
/**
* Deletes the KapmanItem instance.
*/
~KapmanItem() override;
public Q_SLOTS:
/**
* Rotates the image function of the Kapman direction.
*/
void updateDirection();
/**
* Manages the collisions with any Element.
*/
void manageCollision();
/**
* Updates the KapmanItem coordinates.
* @param p_x the new x-coordinate
* @param p_y the new y-coordinate
*/
void update(qreal p_x, qreal p_y) override;
/**
* Starts the KapmanItem animation.
*/
void startAnim();
/**
* Pauses the KapmanItem animation.
*/
void pauseAnim();
/**
* Resumes the KapmanItem animation.
*/
void resumeAnim();
/**
* Stops the KapmanItem animation.
*/
void stopAnim();
/**
* Sets the given frame to the KapmanItem.
* @param p_frame the frame to set
*/
void setFrame(const int p_frame);
/**
* Implements the CharacterItem method.
*/
void startBlinking() override;
/**
* Implements the CharacterItem method.
*/
void blink() override;
/**
* Set if the KapmanItem should be rotated (set by theme flag RotateKapman).
* @param rotate 0 or 1
*/
void setRotationFlag(bool rotate)
{
m_rotationFlag = rotate;
}
};
#endif
|