2 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
3 * Copyright 2007-2008 Alexandre Galinier <alex.galinier@hotmail.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/>.
22 #include "character.h"
27 * @brief This class represents a Ghost for kapman.
29 class Ghost
: public Character
{
35 /** The ghost possible states */
44 /** Max speed ratio, compared with the initial speed */
45 static const qreal MAX_SPEED_RATIO
;
47 /** The path to the Ghost image */
50 /** The ghost current state */
53 /** A list of Cells to go to the camp from the current cell */
54 QList
<QPoint
> m_pathToCamp
;
59 * Creates a new Ghost instance.
60 * @param p_x the initial x-coordinate
61 * @param p_y the initial y-coordinate
62 * @param p_imageId path to the image of the related item
63 * @param p_maze the Maze the Ghost is on
65 Ghost(qreal p_x
, qreal p_y
, const QString
& p_imageId
, Maze
* p_maze
);
68 * Deletes the Ghost instance.
73 * Updates the Ghost move.
78 * Updates the Ghost with a direction to follow.
79 * @param p_row x coordinate of the cell to reach
80 * @param p_col y coordinate of the cell to reach
82 void updateMove(int p_row
, int p_col
);
85 * Gets the path to the Ghost image.
86 * @return the path to the Ghost image
88 QString
getImageId() const;
91 * Gets the current state of the Ghost.
92 * @return the Ghost state
94 State
getState() const;
97 * Sets the Ghost state to the given value.
98 * @param p_state the new Ghost state
100 void setState(Ghost::State p_state
);
103 * Manages the collison with the Kapman.
104 * @param p_kapman the instance of Kapman which collides with the Ghost
106 void doActionOnCollision(Kapman
* p_kapman
);
109 * Initializes the Ghost speed from the Character speed.
116 * Makes the Ghost go up.
121 * Makes the Ghost go down.
126 * Makes the Ghost go to the right.
131 * Makes the Ghost go to the left.
138 * Emitted when the Kapman has lost a life.
143 * Emitted when the Ghost has been eaten.
144 * @param p_ghost the eaten Ghost (this)
146 void ghostEaten(Ghost
* p_ghost
);
149 * Emitted when the Ghost has changed his state.