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 CHARACTERITEM_H |
19 | #define CHARACTERITEM_H |
20 | |
21 | #include "elementitem.h" |
22 | #include "character.h" |
23 | |
24 | #include <QTimer> |
25 | |
26 | /** |
27 | * @brief This class is the graphical representation of a Character. |
28 | */ |
29 | class CharacterItem : public ElementItem { |
30 | |
31 | Q_OBJECT |
32 | |
33 | protected: |
34 | |
35 | /** Timer used to make the character blink */ |
36 | QTimer* m_blinkTimer; |
37 | |
38 | /** Number of ticks of the blink timer */ |
39 | int m_nbBlinks; |
40 | |
41 | public: |
42 | |
43 | /** |
44 | * Creates a new CharacterItem instance. |
45 | * @param p_model the Character model |
46 | */ |
47 | CharacterItem(Character* p_model); |
48 | |
49 | /** |
50 | * Deletes the CharacterItem instance. |
51 | */ |
52 | ~CharacterItem(); |
53 | |
54 | /** |
55 | * Overrides the default shape function to make it a small circle |
56 | * This function is used to determinate collision between items |
57 | * @return QPainterPath the new shape of the Character |
58 | */ |
59 | QPainterPath shape() const; |
60 | |
61 | public slots: |
62 | |
63 | /** |
64 | * Updates the CharacterItem coordinates. |
65 | * @param p_x the new x-coordinate |
66 | * @param p_y the new y-coordinate |
67 | */ |
68 | virtual void update(qreal p_x, qreal p_y); |
69 | |
70 | /** |
71 | * Starts the character blinking. |
72 | */ |
73 | virtual void startBlinking(); |
74 | |
75 | /** |
76 | * Makes the character blink. |
77 | */ |
78 | virtual void blink(); |
79 | }; |
80 | |
81 | #endif |
82 | |
83 | |