SVN_SILENT made messages (.desktop file)
[kdegames.git] / kapman / ghost.h
blobe8d657726437d9a3a2e6a490a1c354d98c7718ec
1 /*
2 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
3 * Copyright 2007-2008 Alexandre Galinier <alex.galinier@hotmail.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 GHOST_H
20 #define GHOST_H
22 #include "character.h"
23 #include "kapman.h"
26 /**
27 * @brief This class represents a Ghost for kapman.
29 class Ghost : public Character {
31 Q_OBJECT
33 public:
35 /** The ghost possible states */
36 enum State {
37 HUNTER = 0,
38 PREY = 1,
39 EATEN = 2
42 private:
44 /** Max speed ratio, compared with the initial speed */
45 static const qreal MAX_SPEED_RATIO;
47 /** The path to the Ghost image */
48 QString m_imageId;
50 /** The ghost current state */
51 State m_state;
53 /** A list of Cells to go to the camp from the current cell */
54 QList<QPoint> m_pathToCamp;
56 public:
58 /**
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);
67 /**
68 * Deletes the Ghost instance.
70 ~Ghost();
72 /**
73 * Updates the Ghost move.
75 void updateMove();
77 /**
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);
84 /**
85 * Gets the path to the Ghost image.
86 * @return the path to the Ghost image
88 QString getImageId() const;
90 /**
91 * Gets the current state of the Ghost.
92 * @return the Ghost state
94 State getState() const;
96 /**
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.
111 void initSpeedInc();
113 private:
116 * Makes the Ghost go up.
118 void goUp();
121 * Makes the Ghost go down.
123 void goDown();
126 * Makes the Ghost go to the right.
128 void goRight();
131 * Makes the Ghost go to the left.
133 void goLeft();
135 signals:
138 * Emitted when the Kapman has lost a life.
140 void lifeLost();
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.
151 void stateChanged();
154 #endif