~ubuntu-branches/ubuntu/trusty/kapman/trusty-proposed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
 * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef KAPMAN_H
#define KAPMAN_H

#include "character.h"

/**
 * @brief This class represents the main character of the game.
 */
class Kapman : public Character {

	Q_OBJECT

	private:

		/** Max speed ratio, compared with the initial speed  */
		static const qreal MAX_SPEED_RATIO;

		/** Kapman asked speed */
		qreal m_askedXSpeed, m_askedYSpeed;

	public:

		/**
		 * Creates a new Kapman instance.
		 * @param p_x the initial x-coordinate
		 * @param p_y the initial y-coordinate
		 * @param p_maze the Maze the Kapman is on
		 */
		Kapman(qreal p_x, qreal p_y, Maze* p_maze);

		/**
		 * Deletes the Kapman instance.
		 */
		~Kapman();

		/**
		 * Initializes the Kapman.
		 */
		void init();

		/**
		 * Makes the Kapman ask to go up
		 */
		void goUp();

		/**
		 * Makes the Kapman ask to go down
		 */
		void goDown();

		/**
		 * Makes the Kapman ask to go to the right
		 */
		void goRight();

		/**
		 * Makes the Kapman ask to go to the left
		 */
		void goLeft();

		/**
		 * Updates the Kapman move
		 */
		void updateMove();

		/**
		 * @return the asked x speed value
		 */
		qreal getAskedXSpeed() const;

		/**
		 * @return the asked y speed value
		 */
		qreal getAskedYSpeed() const;

		/**
		 * Manages the points won
		 * @param p_element reference to the element eaten
		 */
		void winPoints(Element* p_element);

		/**
		 * Implements the Character function
		 */
		void die();
		
		/**
		 * Emits a signal to Kapmanitem in order to manage collisions
		 */
		void emitGameUpdated();

		/**
		 * Initializes the Kapman speed from the Character speed.
		 */
		void initSpeedInc();

	private:

		/**
		 * Updates the Kapman direction with the asked direction
		 */
		void updateDirection();

		/**
		 * @return the next cell the kapman will move on with its asked direction
		 */
		Cell getAskedNextCell();

		/**
		 * Stops moving the Kapman
		 */
		void stopMoving();

	signals:

		/**
		 * Emitted when the direction changed
		 */
		void directionChanged();
		
		/**
		 * Signals to the game that the kapman win points
		 * @param p_element reference to the element eaten
		 */
		void sWinPoints(Element* p_element);

		/**
		 * Signals to Kapmanitem that the game has been updated
		 */
		 void gameUpdated();

		 /**
		  * Emitted when the kapman stops moving
		  */
		 void stopped();
};

#endif