2 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
3 * Copyright 2007-2008 Pierre-BenoƮt Besse <besse.pb@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 * @brief This class describes the common characteristics and behaviour of the game characters (Kapman and the Ghost).
27 class Character
: public Element
{
33 /** Speed on easy level */
34 static const qreal LOW_SPEED
;
36 /** Speed on medium level */
37 static const qreal MEDIUM_SPEED
;
39 /** Speed on hard level */
40 static const qreal HIGH_SPEED
;
42 /** Speed increase on easy level (percentage) */
43 static const qreal LOW_SPEED_INC
;
45 /** Speed increase on medium level (percentage) */
46 static const qreal MEDIUM_SPEED_INC
;
48 /** Speed increase on hard level (percentage) */
49 static const qreal HIGH_SPEED_INC
;
53 /** The Character x-speed */
56 /** The Character y-speed */
59 /** The character speed */
62 /** Reference to the speed of the character when in "normal" behaviour */
65 /** The value the character's speed is incremented by when level up */
66 qreal m_speedIncrease
;
68 /** The maximum character speed */
74 * Creates a new Character instance.
75 * @param p_x the initial x-coordinate
76 * @param p_y the initial y-coordinate
77 * @param p_maze the Maze the Character is on
79 Character(qreal p_x
, qreal p_y
, Maze
* p_maze
);
82 * Deletes the Character instance.
87 * Makes the Character go up.
89 virtual void goUp() = 0;
92 * Makes the Character go down.
94 virtual void goDown() = 0;
97 * Makes the Character go to the right.
99 virtual void goRight() = 0;
102 * Makes the Character go to the left.
104 virtual void goLeft() = 0;
107 * Updates the Character move.
109 virtual void updateMove() = 0;
112 * Moves the Character function of its current coordinates and speed.
113 * If the character reaches a border, it circles around the maze and continue its way from the other side.
118 * Manages the character death (essentially blinking).
123 * Gets the Character x-speed value.
124 * @return the x-speed value
126 qreal
getXSpeed() const;
129 * Gets the Character y-speed value.
130 * @return the y-speed value
132 qreal
getYSpeed() const;
135 * Gets the Character speed.
136 * @return the character speed
141 * Gets the Character normal speed.
142 * @return the character speed reference, when in "normal" behaviour
144 qreal
getNormalSpeed();
147 * Set the Character x-speed value.
148 * @param p_xSpeed the x-speed to set
150 void setXSpeed(qreal p_xSpeed
);
153 * Set the Character y-speed value.
154 * @param p_ySpeed the y-speed to set
156 void setYSpeed(qreal p_ySpeed
);
159 * Initializes the Character speed considering the difficulty level.
164 * Checks the Character is in the line of sight of the given other Character.
165 * @param p_character the other Character
166 * @return true if the Character is in the same line than the given one
168 bool isInLineSight(Character
* p_character
);
171 * Increases the Character speed with each level completed.
173 void increaseCharactersSpeed();
178 * Initializes the Character speed increment considering the difficulty level.
180 virtual void initSpeedInc() = 0;
183 * Gets the next Cell the Character is going to reach.
184 * @return the next Cell the Character is going to reach
189 * Checks the Character gets on a Cell center during its next movement.
190 * @return true if the Character is on a Cell center, false otherwise
195 * Moves the character on the center of its current Cell.
202 * Emitted when the character is eaten.