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

granatier

  • sources
  • kde-4.14
  • kdegames
  • granatier
  • src
character.h
Go to the documentation of this file.
1 /*
2  * Copyright 2009 Mathias Kraus <k.hias@gmx.de>
3  * Copyright 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
4  * Copyright 2007-2008 Pierre-BenoĆ®t Besse <besse.pb@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef CHARACTER_H
21 #define CHARACTER_H
22 
23 #include "element.h"
24 
25 #include <QKeySequence>
26 
27 
31 class Character : public Element {
32 
33 Q_OBJECT
34 
35 public:
36 
38  struct Shortcuts
39  {
40  QKeySequence moveLeft;
41  QKeySequence moveRight;
42  QKeySequence moveUp;
43  QKeySequence moveDown;
44  QKeySequence dropBomb;
45  };
46  Shortcuts m_key;
47 
48 protected:
49 
51  qreal m_xSpeed;
52 
54  qreal m_ySpeed;
55 
57  qreal m_speed;
58 
60  qreal m_normalSpeed;
61 
63  qreal m_maxSpeed;
64 
65 public:
66 
73  Character(qreal p_x, qreal p_y, Arena* p_arena);
74 
78  ~Character();
79 
83  virtual void goUp() = 0;
84 
88  virtual void goDown() = 0;
89 
93  virtual void goRight() = 0;
94 
98  virtual void goLeft() = 0;
99 
103  virtual void updateMove() = 0;
104 
109  void move();
110 
114  void die();
115 
120  qreal getXSpeed() const;
121 
126  qreal getYSpeed() const;
127 
132  qreal getSpeed() const;
133 
138  qreal getNormalSpeed() const;
139 
144  void setXSpeed(qreal p_xSpeed);
145 
150  void setYSpeed(qreal p_ySpeed);
151 
155  void initSpeed();
156 
162  bool isInLineSight(Character* p_character) const;
163 
164 signals:
165 
169  void dead();
170 };
171 
172 #endif
173 
Character::m_key
Shortcuts m_key
Definition: character.h:46
element.h
Character::getXSpeed
qreal getXSpeed() const
Gets the Character x-speed value.
Definition: character.cpp:63
Character::Shortcuts::moveRight
QKeySequence moveRight
Definition: character.h:41
Character::goUp
virtual void goUp()=0
Makes the Character go up.
Character
This class describes the common characteristics and behaviour of the game characters (Players)...
Definition: character.h:31
Character::updateMove
virtual void updateMove()=0
Updates the Character move.
Character::Character
Character(qreal p_x, qreal p_y, Arena *p_arena)
Creates a new Character instance.
Definition: character.cpp:23
Character::setXSpeed
void setXSpeed(qreal p_xSpeed)
Set the Character x-speed value.
Definition: character.cpp:83
Character::setYSpeed
void setYSpeed(qreal p_ySpeed)
Set the Character y-speed value.
Definition: character.cpp:88
Character::Shortcuts
Keyboard shortcuts for moving and dropping a bomb.
Definition: character.h:38
Character::goDown
virtual void goDown()=0
Makes the Character go down.
Character::getYSpeed
qreal getYSpeed() const
Gets the Character y-speed value.
Definition: character.cpp:68
Character::isInLineSight
bool isInLineSight(Character *p_character) const
Checks the Character is in the line of sight of the given other Character.
Definition: character.cpp:100
Character::Shortcuts::moveDown
QKeySequence moveDown
Definition: character.h:43
Character::move
void move()
Moves the Character function of its current coordinates and speed.
Definition: character.cpp:33
Arena
This class represents the Arena of the game.
Definition: arena.h:36
Character::initSpeed
void initSpeed()
Initializes the Character speed considering the difficulty level.
Definition: character.cpp:93
Character::dead
void dead()
Emitted when the character is dead.
Element
This class describes the common characteristics and behaviour of any game Element (character or item)...
Definition: element.h:32
Character::getNormalSpeed
qreal getNormalSpeed() const
Gets the Character normal speed.
Definition: character.cpp:78
Character::m_ySpeed
qreal m_ySpeed
The Character y-speed.
Definition: character.h:54
Character::Shortcuts::moveLeft
QKeySequence moveLeft
Definition: character.h:40
Character::m_xSpeed
qreal m_xSpeed
The Character x-speed.
Definition: character.h:51
Character::getSpeed
qreal getSpeed() const
Gets the Character speed.
Definition: character.cpp:73
Character::~Character
~Character()
Deletes the Character instance.
Definition: character.cpp:29
QKeySequence
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:58
Character::m_maxSpeed
qreal m_maxSpeed
The maximum character speed.
Definition: character.h:63
Character::Shortcuts::dropBomb
QKeySequence dropBomb
Definition: character.h:44
Character::m_normalSpeed
qreal m_normalSpeed
Reference to the speed of the character when in "normal" behaviour.
Definition: character.h:60
Character::Shortcuts::moveUp
QKeySequence moveUp
Definition: character.h:42
Character::m_speed
qreal m_speed
The character speed.
Definition: character.h:57
Character::goLeft
virtual void goLeft()=0
Makes the Character go to the left.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:10 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

granatier

Skip menu "granatier"
  • Main Page
  • Namespace List
  • Namespace Members
  • 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