SVN_SILENT made messages (.desktop file)
[kdegames.git] / kapman / character.h
blob6115a296fc53f0a204f7f82c7ec249abaa5d2271
1 /*
2 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
3 * Copyright 2007-2008 Pierre-BenoƮt Besse <besse.pb@gmail.com>
4 *
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.
9 *
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/>.
19 #ifndef CHARACTER_H
20 #define CHARACTER_H
22 #include "element.h"
24 /**
25 * @brief This class describes the common characteristics and behaviour of the game characters (Kapman and the Ghost).
27 class Character : public Element {
29 Q_OBJECT
31 public:
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;
51 protected:
53 /** The Character x-speed */
54 qreal m_xSpeed;
56 /** The Character y-speed */
57 qreal m_ySpeed;
59 /** The character speed */
60 qreal m_speed;
62 /** Reference to the speed of the character when in "normal" behaviour */
63 qreal m_normalSpeed;
65 /** The value the character's speed is incremented by when level up */
66 qreal m_speedIncrease;
68 /** The maximum character speed */
69 qreal m_maxSpeed;
71 public:
73 /**
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);
81 /**
82 * Deletes the Character instance.
84 ~Character();
86 /**
87 * Makes the Character go up.
89 virtual void goUp() = 0;
91 /**
92 * Makes the Character go down.
94 virtual void goDown() = 0;
96 /**
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.
115 void move();
118 * Manages the character death (essentially blinking).
120 void die();
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
138 qreal getSpeed();
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.
161 void initSpeed();
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();
175 protected:
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
186 Cell getNextCell();
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
192 bool onCenter();
195 * Moves the character on the center of its current Cell.
197 void moveOnCenter();
199 signals:
202 * Emitted when the character is eaten.
204 void eaten();
207 #endif