• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

kapman

  • sources
  • kde-4.14
  • kdegames
  • kapman
character.h
Go to the documentation of this file.
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 
27 class Character : public Element {
28 
29  Q_OBJECT
30 
31  public:
32 
34  static const qreal LOW_SPEED;
35 
37  static const qreal MEDIUM_SPEED;
38 
40  static const qreal HIGH_SPEED;
41 
43  static const qreal LOW_SPEED_INC;
44 
46  static const qreal MEDIUM_SPEED_INC;
47 
49  static const qreal HIGH_SPEED_INC;
50 
51  protected:
52 
54  qreal m_xSpeed;
55 
57  qreal m_ySpeed;
58 
60  qreal m_speed;
61 
63  qreal m_normalSpeed;
64 
66  qreal m_speedIncrease;
67 
69  qreal m_maxSpeed;
70 
71  public:
72 
79  Character(qreal p_x, qreal p_y, Maze* p_maze);
80 
84  ~Character();
85 
89  virtual void goUp() = 0;
90 
94  virtual void goDown() = 0;
95 
99  virtual void goRight() = 0;
100 
104  virtual void goLeft() = 0;
105 
109  virtual void updateMove() = 0;
110 
115  void move();
116 
120  void die();
121 
126  qreal getXSpeed() const;
127 
132  qreal getYSpeed() const;
133 
138  qreal getSpeed() const;
139 
144  qreal getNormalSpeed() const;
145 
150  void setXSpeed(qreal p_xSpeed);
151 
156  void setYSpeed(qreal p_ySpeed);
157 
161  void initSpeed();
162 
168  bool isInLineSight(Character* p_character);
169 
173  void increaseCharactersSpeed();
174 
175  protected:
176 
180  virtual void initSpeedInc() = 0;
181 
186  Cell getNextCell();
187 
192  bool onCenter();
193 
197  void moveOnCenter();
198 
199  signals:
200 
204  void eaten();
205 };
206 
207 #endif
208 
element.h
Cell
This class represents a Cell of the Maze.
Definition: cell.h:28
Character::getXSpeed
qreal getXSpeed() const
Gets the Character x-speed value.
Definition: character.cpp:59
Character::m_speedIncrease
qreal m_speedIncrease
The value the character's speed is incremented by when level up.
Definition: character.h:66
Character::eaten
void eaten()
Emitted when the character is eaten.
Character::initSpeedInc
virtual void initSpeedInc()=0
Initializes the Character speed increment considering the difficulty level.
Character::goUp
virtual void goUp()=0
Makes the Character go up.
Character
This class describes the common characteristics and behaviour of the game characters (Kapman and the ...
Definition: character.h:27
Character::updateMove
virtual void updateMove()=0
Updates the Character move.
Character::setXSpeed
void setXSpeed(qreal p_xSpeed)
Set the Character x-speed value.
Definition: character.cpp:75
Character::setYSpeed
void setYSpeed(qreal p_ySpeed)
Set the Character y-speed value.
Definition: character.cpp:79
Character::HIGH_SPEED
static const qreal HIGH_SPEED
Speed on hard level.
Definition: character.h:40
Character::getNextCell
Cell getNextCell()
Gets the next Cell the Character is going to reach.
Definition: character.cpp:171
Character::goDown
virtual void goDown()=0
Makes the Character go down.
Character::LOW_SPEED_INC
static const qreal LOW_SPEED_INC
Speed increase on easy level (percentage)
Definition: character.h:43
Character::getYSpeed
qreal getYSpeed() const
Gets the Character y-speed value.
Definition: character.cpp:63
Character::move
void move()
Moves the Character function of its current coordinates and speed.
Definition: character.cpp:38
Character::increaseCharactersSpeed
void increaseCharactersSpeed()
Increases the Character speed with each level completed.
Definition: character.cpp:100
Character::initSpeed
void initSpeed()
Initializes the Character speed considering the difficulty level.
Definition: character.cpp:83
Character::onCenter
bool onCenter()
Checks the Character gets on a Cell center during its next movement.
Definition: character.cpp:191
Character::LOW_SPEED
static const qreal LOW_SPEED
Speed on easy level.
Definition: character.h:34
Character::MEDIUM_SPEED
static const qreal MEDIUM_SPEED
Speed on medium level.
Definition: character.h:37
Element
This class describes the common characteristics and behaviour of any game Element (character or item)...
Definition: element.h:30
Character::getNormalSpeed
qreal getNormalSpeed() const
Gets the Character normal speed.
Definition: character.cpp:71
Character::m_ySpeed
qreal m_ySpeed
The Character y-speed.
Definition: character.h:57
Character::m_xSpeed
qreal m_xSpeed
The Character x-speed.
Definition: character.h:54
Character::getSpeed
qreal getSpeed() const
Gets the Character speed.
Definition: character.cpp:67
Character::~Character
~Character()
Deletes the Character instance.
Definition: character.cpp:35
Character::goRight
virtual void goRight()=0
Makes the Character go to the right.
Character::die
void die()
Manages the character death (essentially blinking).
Definition: character.cpp:55
Character::MEDIUM_SPEED_INC
static const qreal MEDIUM_SPEED_INC
Speed increase on medium level (percentage)
Definition: character.h:46
Character::m_maxSpeed
qreal m_maxSpeed
The maximum character speed.
Definition: character.h:69
Character::m_normalSpeed
qreal m_normalSpeed
Reference to the speed of the character when in "normal" behaviour.
Definition: character.h:63
Character::moveOnCenter
void moveOnCenter()
Moves the character on the center of its current Cell.
Definition: character.cpp:222
Character::Character
Character(qreal p_x, qreal p_y, Maze *p_maze)
Creates a new Character instance.
Definition: character.cpp:30
Character::m_speed
qreal m_speed
The character speed.
Definition: character.h:60
Maze
This class represents the Maze of the game.
Definition: maze.h:31
Character::HIGH_SPEED_INC
static const qreal HIGH_SPEED_INC
Speed increase on hard level (percentage)
Definition: character.h:49
Character::goLeft
virtual void goLeft()=0
Makes the Character go to the left.
Character::isInLineSight
bool isInLineSight(Character *p_character)
Checks the Character is in the line of sight of the given other Character.
Definition: character.cpp:109
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:15 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kapman

Skip menu "kapman"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal