• 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
player.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  *
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 PLAYER_H
20 #define PLAYER_H
21 
22 #include "character.h"
23 
24 class PlayerSettings;
25 class QKeyEvent;
26 class QString;
27 class QTimer;
28 class Bonus;
29 
33 class Player : public Character
34 {
35  Q_OBJECT
36 
37 private:
39  QString m_playerName;
40  QString m_desktopFilePath;
41  QString m_graphicsFile;
42 
44  qreal m_askedXSpeed, m_askedYSpeed;
45 
47  int m_direction;
48 
50  int m_bombPower;
51 
53  int m_maxBombArmory;
54 
56  int m_bombArmory;
57 
59  bool m_death;
60 
62  int m_points;
63 
65  bool m_onIce;
66 
68  bool m_falling;
69 
71  bool m_throwBomb;
72 
74  bool m_kickBomb;
75 
77  bool m_omitBombCurrentCell;
78 
80  QList <int> m_listShield;
81 
83  Granatier::Bonus::Type m_badBonusType;
84 
86  qreal m_normalSpeed;
87 
89  int m_normalBombArmory;
90 
92  bool m_moveMirrored;
93 
95  QTimer* m_badBonusCountdownTimer;
97  int m_badBonusMillisecondsToElapse;
98 
99 
100 
101 public:
110  Player(qreal p_x, qreal p_y, const QString& p_playerID, const PlayerSettings* p_playerSettings, Arena* p_arena);
111 
115  ~Player();
116 
120  void setShortcuts(const Shortcuts &keys);
121 
126  QString getGraphicsFile() const;
127 
132  QString getDesktopFilePath() const;
133 
138  QString getPlayerName() const;
139 
143  void init();
144 
148  void pause();
149 
153  void resume();
154 
158  void goUp();
159 
163  void goDown();
164 
168  void goRight();
169 
173  void goLeft();
174 
178  void move(qreal x, qreal y);
179 
183  void updateMove();
184 
188  qreal getAskedXSpeed() const;
189 
193  qreal getAskedYSpeed() const;
194 
198  int direction();
199 
203  int getBombPower() const;
204 
208  void decrementBombArmory();
209 
214  void addBonus(Bonus* p_bonus);
215 
221  bool shield(int n_ExplosionID);
222 
226  bool hasShield();
227 
231  bool hasThrowBomb();
232 
236  bool hasKickBomb();
237 
241  bool hasBadBonus();
242 
246  void die();
247 
251  bool isAlive() const;
252 
256  void resurrect();
257 
261  int points() const;
262 
266  void addPoint();
267 
271  void emitGameUpdated();
272 
276  void keyPressed(QKeyEvent* keyEvent);
277 
281  void keyReleased(QKeyEvent* keyEvent);
282 
286  //TODO: find a better place
287  int signZeroPositive(const qreal value);
291  int sign(const qreal value);
292 
293 private:
297  void updateDirection();
298 
302  void stopMoving();
303 
304 public slots:
308  void slot_refillBombArmory();
309 
310 private slots:
314  void slot_removeBadBonus();
315 
319  void slot_badBonusTimerTimeout();
320 
321 signals:
325  void directionChanged();
326 
330  void gameUpdated();
331 
335  void stopped();
336 
340  void bombDropped(Player* player, qreal x, qreal y, bool newBomb, int throwDistance);
341 
345  void dying();
346 
350  void falling();
351 
355  void resurrectBonusTaken();
356 
360  void resurrected();
361 
368  void bonusUpdated(Player* player, Granatier::Bonus::Type bonusType, int percentageElapsed);
369 };
370 
371 #endif
character.h
Player::stopped
void stopped()
Emitted when the player stops moving.
Player::emitGameUpdated
void emitGameUpdated()
Emits a signal to PlayerItem in order to manage collisions.
Definition: player.cpp:804
Player::direction
int direction()
Definition: player.cpp:819
Player::sign
int sign(const qreal value)
Returns the sign of a value with 0 for zero.
Definition: player.cpp:1053
Player::addBonus
void addBonus(Bonus *p_bonus)
Manages the points won.
Definition: player.cpp:514
Player::hasThrowBomb
bool hasThrowBomb()
Definition: player.cpp:690
Bonus
This class represents a Bonus for the Player.
Definition: bonus.h:29
Player::getBombPower
int getBombPower() const
Definition: player.cpp:824
Character
This class describes the common characteristics and behaviour of the game characters (Players)...
Definition: character.h:31
Player::getPlayerName
QString getPlayerName() const
Gets the Player name.
Definition: player.cpp:80
Player::getDesktopFilePath
QString getDesktopFilePath() const
Gets the path to the Player Desktop file.
Definition: player.cpp:75
Player::keyPressed
void keyPressed(QKeyEvent *keyEvent)
Manages the keys for moving and dropping bombs.
Definition: player.cpp:939
Player::goDown
void goDown()
Makes the Player ask to go down.
Definition: player.cpp:121
Player::bombDropped
void bombDropped(Player *player, qreal x, qreal y, bool newBomb, int throwDistance)
Emitted when the player drops a bomb.
Player::resurrect
void resurrect()
resurrects the player
Definition: player.cpp:734
Player::addPoint
void addPoint()
adds a point
Definition: player.cpp:799
Player::dying
void dying()
Emitted when the player is dying.
Player::goLeft
void goLeft()
Makes the Player ask to go to the left.
Definition: player.cpp:149
Player::pause
void pause()
pause the timer
Definition: player.cpp:94
Player::points
int points() const
returns the points
Definition: player.cpp:794
Player::isAlive
bool isAlive() const
returns if the player is alive
Definition: player.cpp:729
Player::keyReleased
void keyReleased(QKeyEvent *keyEvent)
Manages the keys for moving and dropping bombs.
Definition: player.cpp:996
Player::gameUpdated
void gameUpdated()
Signals to PlayerItem that the game has been updated.
Character::Shortcuts
Keyboard shortcuts for moving and dropping a bomb.
Definition: character.h:38
Player::Player
Player(qreal p_x, qreal p_y, const QString &p_playerID, const PlayerSettings *p_playerSettings, Arena *p_arena)
Creates a new Player instance.
Definition: player.cpp:35
Player::resume
void resume()
resume the timer
Definition: player.cpp:99
QTimer
Player::updateMove
void updateMove()
Updates the Player move.
Definition: player.cpp:178
Player::bonusUpdated
void bonusUpdated(Player *player, Granatier::Bonus::Type bonusType, int percentageElapsed)
Emitted when the player has taken a bonus.
Player::falling
void falling()
Emitted when the player is falling in a hole.
Player::directionChanged
void directionChanged()
Emitted when the direction changed.
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
Player::setShortcuts
void setShortcuts(const Shortcuts &keys)
Shortcuts for moving and dropping bombs.
Definition: player.cpp:65
Player::getAskedXSpeed
qreal getAskedXSpeed() const
Definition: player.cpp:809
PlayerSettings
Definition: playersettings.h:27
QString
QList< int >
Player::decrementBombArmory
void decrementBombArmory()
decrements the bomb armory
Definition: player.cpp:829
Player::hasBadBonus
bool hasBadBonus()
Definition: player.cpp:700
Player::die
void die()
Implements the Character function.
Definition: player.cpp:709
Player::goUp
void goUp()
Makes the Player ask to go up.
Definition: player.cpp:107
QKeyEvent
Player::getGraphicsFile
QString getGraphicsFile() const
Gets the file for the Player SVG.
Definition: player.cpp:70
Player::resurrected
void resurrected()
Emitted when the player has resurrected.
Player::signZeroPositive
int signZeroPositive(const qreal value)
Returns the sign of a value with a positive sign for zero.
Definition: player.cpp:1048
Player::hasShield
bool hasShield()
Definition: player.cpp:681
Player::getAskedYSpeed
qreal getAskedYSpeed() const
Definition: player.cpp:814
Player::resurrectBonusTaken
void resurrectBonusTaken()
Emitted when the player has taken the resurrect bonus.
Player::~Player
~Player()
Deletes the Player instance.
Definition: player.cpp:60
Player::goRight
void goRight()
Makes the Player ask to go to the right.
Definition: player.cpp:135
Player::shield
bool shield(int n_ExplosionID)
Manages the points won.
Definition: player.cpp:660
Player
This class represents the main character of the game.
Definition: player.h:33
Granatier::Bonus::Type
Type
Definition: granatierglobals.h:103
Player::slot_refillBombArmory
void slot_refillBombArmory()
refills the bomb armory after a bomb is exploded
Definition: player.cpp:838
Player::hasKickBomb
bool hasKickBomb()
Definition: player.cpp:695
Player::init
void init()
Initializes the Player.
Definition: player.cpp:85
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