File indexing completed on 2023-10-01 08:02:05
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 Thomas Gallinari <tg8187@yahoo.fr> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KAPMANITEM_H 0008 #define KAPMANITEM_H 0009 0010 #include "characteritem.h" 0011 #include "kapman.h" 0012 0013 #include <QTimeLine> 0014 0015 /** 0016 * @brief This class manage the display of the Kapman. 0017 */ 0018 class KapmanItem : public CharacterItem 0019 { 0020 Q_OBJECT 0021 0022 private: 0023 /** Number of frames to animate the KapmanItem */ 0024 static const int NB_FRAMES; 0025 0026 /** Animation update interval */ 0027 static const int ANIM_LOW_SPEED; 0028 static const int ANIM_MEDIUM_SPEED; 0029 static const int ANIM_HIGH_SPEED; 0030 0031 /** Timer used to animate the KapmanItem */ 0032 QTimeLine *m_animationTimer; 0033 0034 /** Rotation flag set by theme */ 0035 bool m_rotationFlag; 0036 0037 public: 0038 /** 0039 * Creates a new KapmanItem instance. 0040 * @param p_model the Kapman model 0041 */ 0042 explicit KapmanItem(Kapman *p_model); 0043 0044 /** 0045 * Deletes the KapmanItem instance. 0046 */ 0047 ~KapmanItem() override; 0048 0049 public Q_SLOTS: 0050 0051 /** 0052 * Rotates the image function of the Kapman direction. 0053 */ 0054 void updateDirection(); 0055 0056 /** 0057 * Manages the collisions with any Element. 0058 */ 0059 void manageCollision(); 0060 0061 /** 0062 * Updates the KapmanItem coordinates. 0063 * @param p_x the new x-coordinate 0064 * @param p_y the new y-coordinate 0065 */ 0066 void update(qreal p_x, qreal p_y) override; 0067 0068 /** 0069 * Starts the KapmanItem animation. 0070 */ 0071 void startAnim(); 0072 0073 /** 0074 * Pauses the KapmanItem animation. 0075 */ 0076 void pauseAnim(); 0077 0078 /** 0079 * Resumes the KapmanItem animation. 0080 */ 0081 void resumeAnim(); 0082 0083 /** 0084 * Stops the KapmanItem animation. 0085 */ 0086 void stopAnim(); 0087 0088 /** 0089 * Sets the given frame to the KapmanItem. 0090 * @param p_frame the frame to set 0091 */ 0092 void setFrame(const int p_frame); 0093 0094 /** 0095 * Implements the CharacterItem method. 0096 */ 0097 void startBlinking() override; 0098 0099 /** 0100 * Implements the CharacterItem method. 0101 */ 0102 void blink() override; 0103 0104 /** 0105 * Set if the KapmanItem should be rotated (set by theme flag RotateKapman). 0106 * @param rotate 0 or 1 0107 */ 0108 void setRotationFlag(bool rotate) 0109 { 0110 m_rotationFlag = rotate; 0111 } 0112 }; 0113 0114 #endif