~ubuntu-branches/ubuntu/vivid/kapman/vivid-proposed

« back to all changes in this revision

Viewing changes to character.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-12-07 17:37:19 UTC
  • Revision ID: package-import@ubuntu.com-20121207173719-5973b949kqub4zup
Tags: upstream-4.9.90
Import upstream version 4.9.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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.
 
14
 * 
 
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/>.
 
17
 */
 
18
 
 
19
#ifndef CHARACTER_H
 
20
#define CHARACTER_H
 
21
 
 
22
#include "element.h"
 
23
 
 
24
/**
 
25
 * @brief This class describes the common characteristics and behaviour of the game characters (Kapman and the Ghost).
 
26
 */
 
27
class Character : public Element {
 
28
 
 
29
        Q_OBJECT
 
30
 
 
31
        public:
 
32
 
 
33
                /** Speed on easy level */
 
34
                static const qreal LOW_SPEED;
 
35
 
 
36
                /** Speed on medium level */
 
37
                static const qreal MEDIUM_SPEED;
 
38
 
 
39
                /** Speed on hard level */
 
40
                static const qreal HIGH_SPEED;
 
41
 
 
42
                /** Speed increase on easy level (percentage)  */
 
43
                static const qreal LOW_SPEED_INC;
 
44
 
 
45
                /** Speed increase on medium level (percentage)  */
 
46
                static const qreal MEDIUM_SPEED_INC;
 
47
 
 
48
                /** Speed increase on hard level (percentage) */
 
49
                static const qreal HIGH_SPEED_INC;
 
50
 
 
51
        protected:
 
52
 
 
53
                /** The Character x-speed */
 
54
                qreal m_xSpeed;
 
55
 
 
56
                /** The Character y-speed */
 
57
                qreal m_ySpeed;
 
58
 
 
59
                /** The character speed */
 
60
                qreal m_speed;
 
61
 
 
62
                /** Reference to the speed of the character when in "normal" behaviour */
 
63
                qreal m_normalSpeed;
 
64
 
 
65
                /** The value the character's speed is incremented by when level up */
 
66
                qreal m_speedIncrease;
 
67
 
 
68
                /** The maximum character speed */
 
69
                qreal m_maxSpeed;
 
70
 
 
71
        public:
 
72
 
 
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
 
78
                 */
 
79
                Character(qreal p_x, qreal p_y, Maze* p_maze);
 
80
 
 
81
                /**
 
82
                 * Deletes the Character instance.
 
83
                 */
 
84
                ~Character();
 
85
 
 
86
                /**
 
87
                 * Makes the Character go up.
 
88
                 */
 
89
                virtual void goUp() = 0;
 
90
 
 
91
                /**
 
92
                 * Makes the Character go down.
 
93
                 */
 
94
                virtual void goDown() = 0;
 
95
 
 
96
                /**
 
97
                 * Makes the Character go to the right.
 
98
                 */
 
99
                virtual void goRight() = 0;
 
100
 
 
101
                /**
 
102
                 * Makes the Character go to the left.
 
103
                 */
 
104
                virtual void goLeft() = 0;
 
105
 
 
106
                /**
 
107
                 * Updates the Character move.
 
108
                 */
 
109
                virtual void updateMove() = 0;
 
110
 
 
111
                /**
 
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.
 
114
                 */
 
115
                void move();
 
116
 
 
117
                /**
 
118
                 * Manages the character death (essentially blinking).
 
119
                 */
 
120
                void die();
 
121
 
 
122
                /**
 
123
                 * Gets the Character x-speed value.
 
124
                 * @return the x-speed value
 
125
                 */
 
126
                qreal getXSpeed() const;
 
127
 
 
128
                /**
 
129
                 * Gets the Character y-speed value.
 
130
                 * @return the y-speed value
 
131
                 */
 
132
                qreal getYSpeed() const;
 
133
 
 
134
                /**
 
135
                 * Gets the Character speed.
 
136
                 * @return the character speed
 
137
                 */
 
138
                qreal getSpeed() const;
 
139
 
 
140
                /**
 
141
                 * Gets the Character normal speed.
 
142
                 * @return the character speed reference, when in "normal" behaviour
 
143
                 */
 
144
                qreal getNormalSpeed() const;
 
145
                
 
146
                /**
 
147
                 * Set the Character x-speed value.
 
148
                 * @param p_xSpeed the x-speed to set
 
149
                 */
 
150
                 void setXSpeed(qreal p_xSpeed);
 
151
                 
 
152
                /**
 
153
                 * Set the Character y-speed value.
 
154
                 * @param p_ySpeed the y-speed to set
 
155
                 */
 
156
                 void setYSpeed(qreal p_ySpeed);
 
157
 
 
158
                /**
 
159
                 * Initializes the Character speed considering the difficulty level.
 
160
                 */
 
161
                void initSpeed();
 
162
 
 
163
                /**
 
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
 
167
                 */
 
168
                bool isInLineSight(Character* p_character);
 
169
 
 
170
                /**
 
171
                 * Increases the Character speed with each level completed.
 
172
                 */
 
173
                void increaseCharactersSpeed();
 
174
 
 
175
        protected:
 
176
 
 
177
                /**
 
178
                 * Initializes the Character speed increment considering the difficulty level.
 
179
                 */
 
180
                virtual void initSpeedInc() = 0;
 
181
                 
 
182
                /**
 
183
                 * Gets the next Cell the Character is going to reach.
 
184
                 * @return the next Cell the Character is going to reach
 
185
                 */
 
186
                Cell getNextCell();
 
187
 
 
188
                /**
 
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
 
191
                 */
 
192
                bool onCenter();
 
193
 
 
194
                /**
 
195
                 * Moves the character on the center of its current Cell.
 
196
                 */
 
197
                void moveOnCenter();
 
198
 
 
199
        signals:
 
200
 
 
201
                /**
 
202
                 * Emitted when the character is eaten.
 
203
                 */
 
204
                void eaten();
 
205
};
 
206
 
 
207
#endif
 
208