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 KAPMAN_H |
19 | #define KAPMAN_H |
20 | |
21 | #include "character.h" |
22 | |
23 | /** |
24 | * @brief This class represents the main character of the game. |
25 | */ |
26 | class Kapman : public Character { |
27 | |
28 | Q_OBJECT |
29 | |
30 | private: |
31 | |
32 | /** Max speed ratio, compared with the initial speed */ |
33 | static const qreal MAX_SPEED_RATIO; |
34 | |
35 | /** Kapman asked speed */ |
36 | qreal m_askedXSpeed, m_askedYSpeed; |
37 | |
38 | public: |
39 | |
40 | /** |
41 | * Creates a new Kapman instance. |
42 | * @param p_x the initial x-coordinate |
43 | * @param p_y the initial y-coordinate |
44 | * @param p_maze the Maze the Kapman is on |
45 | */ |
46 | Kapman(qreal p_x, qreal p_y, Maze* p_maze); |
47 | |
48 | /** |
49 | * Deletes the Kapman instance. |
50 | */ |
51 | ~Kapman(); |
52 | |
53 | /** |
54 | * Initializes the Kapman. |
55 | */ |
56 | void init(); |
57 | |
58 | /** |
59 | * Makes the Kapman ask to go up |
60 | */ |
61 | void goUp(); |
62 | |
63 | /** |
64 | * Makes the Kapman ask to go down |
65 | */ |
66 | void goDown(); |
67 | |
68 | /** |
69 | * Makes the Kapman ask to go to the right |
70 | */ |
71 | void goRight(); |
72 | |
73 | /** |
74 | * Makes the Kapman ask to go to the left |
75 | */ |
76 | void goLeft(); |
77 | |
78 | /** |
79 | * Updates the Kapman move |
80 | */ |
81 | void updateMove(); |
82 | |
83 | /** |
84 | * @return the asked x speed value |
85 | */ |
86 | qreal getAskedXSpeed() const; |
87 | |
88 | /** |
89 | * @return the asked y speed value |
90 | */ |
91 | qreal getAskedYSpeed() const; |
92 | |
93 | /** |
94 | * Manages the points won |
95 | * @param p_element reference to the element eaten |
96 | */ |
97 | void winPoints(Element* p_element); |
98 | |
99 | /** |
100 | * Implements the Character function |
101 | */ |
102 | void die(); |
103 | |
104 | /** |
105 | * Emits a signal to Kapmanitem in order to manage collisions |
106 | */ |
107 | void emitGameUpdated(); |
108 | |
109 | /** |
110 | * Initializes the Kapman speed from the Character speed. |
111 | */ |
112 | void initSpeedInc(); |
113 | |
114 | private: |
115 | |
116 | /** |
117 | * Updates the Kapman direction with the asked direction |
118 | */ |
119 | void updateDirection(); |
120 | |
121 | /** |
122 | * @return the next cell the kapman will move on with its asked direction |
123 | */ |
124 | Cell getAskedNextCell(); |
125 | |
126 | /** |
127 | * Stops moving the Kapman |
128 | */ |
129 | void stopMoving(); |
130 | |
131 | signals: |
132 | |
133 | /** |
134 | * Emitted when the direction changed |
135 | */ |
136 | void directionChanged(); |
137 | |
138 | /** |
139 | * Signals to the game that the kapman win points |
140 | * @param p_element reference to the element eaten |
141 | */ |
142 | void sWinPoints(Element* p_element); |
143 | |
144 | /** |
145 | * Signals to Kapmanitem that the game has been updated |
146 | */ |
147 | void gameUpdated(); |
148 | |
149 | /** |
150 | * Emitted when the kapman stops moving |
151 | */ |
152 | void stopped(); |
153 | }; |
154 | |
155 | #endif |
156 | |