• 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
element.cpp
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 #include "element.h"
20 
21 Element::Element(qreal p_x, qreal p_y, Arena* p_arena) : m_xInit(p_x), m_yInit(p_y), m_arena(p_arena)
22 {
23  initCoordinate();
24 }
25 
26 Element::~Element()
27 {
28 }
29 
30 void Element::doActionOnCollision(Player*)
31 {
32  // Do nothing by default : will be redefined within the subclasses
33 }
34 
35 void Element::setArena(Arena* p_arena)
36 {
37  m_arena = p_arena;
38 }
39 
40 void Element::setInitialCoordinates (qreal p_x, qreal p_y)
41 {
42  m_xInit = p_x;
43  m_yInit = p_y;
44 }
45 
46 qreal Element::getX() const
47 {
48  return m_x;
49 }
50 
51 qreal Element::getY() const
52 {
53  return m_y;
54 }
55 
56 void Element::setX(qreal p_x)
57 {
58  m_x = p_x;
59  emit(moved(m_x, m_y));
60 }
61 
62 void Element::setY(qreal p_y)
63 {
64  m_y = p_y;
65  emit(moved(m_x, m_y));
66 }
67 
68 Granatier::Element::Type Element::getType() const
69 {
70  return m_type;
71 }
72 
73 QString Element::getImageId() const
74 {
75  return m_imageId;
76 }
77 
78 void Element::setImageId(const QString & p_imageId)
79 {
80  m_imageId = p_imageId;
81 }
82 
83 void Element::initCoordinate()
84 {
85  setX(m_xInit);
86  setY(m_yInit);
87 }
Element::initCoordinate
void initCoordinate()
Initializes Element x-coordinate and y-coordinate with initial values.
Definition: element.cpp:83
Element::setImageId
void setImageId(const QString &p_imageId)
Sets the Element image.
Definition: element.cpp:78
Element::m_type
Granatier::Element::Type m_type
The Element type.
Definition: element.h:39
Element::m_x
qreal m_x
The Element current x-coordinate.
Definition: element.h:48
element.h
Element::m_y
qreal m_y
The Element current y-coordinate.
Definition: element.h:51
Element::getX
qreal getX() const
Gets the Element x-coordinate.
Definition: element.cpp:46
Element::setY
void setY(qreal p_y)
Sets the Element y-coordinate to the given value.
Definition: element.cpp:62
Element::getImageId
QString getImageId() const
Gets the path to the Element image.
Definition: element.cpp:73
Element::getType
Granatier::Element::Type getType() const
Gets the type of the Element.
Definition: element.cpp:68
Element::setArena
void setArena(Arena *p_arena)
Sets arena for the element.
Definition: element.cpp:35
Element::setX
void setX(qreal p_x)
Sets the Element x-coordinate to the given value.
Definition: element.cpp:56
Element::m_xInit
qreal m_xInit
The Element initial x-coordinate.
Definition: element.h:42
Element::moved
void moved(qreal p_x, qreal p_y)
Emitted on Element move.
Element::m_arena
Arena * m_arena
The Arena the Element is on.
Definition: element.h:54
Element::setInitialCoordinates
void setInitialCoordinates(qreal p_x, qreal p_y)
Sets the path initial position.
Definition: element.cpp:40
Element::Element
Element(qreal p_x, qreal p_y, Arena *p_arena)
Creates a new Element instance.
Definition: element.cpp:21
Element::doActionOnCollision
virtual void doActionOnCollision(Player *p_player)
Computes an action on a collision with the Player.
Definition: element.cpp:30
Element::~Element
~Element()
Deletes the Element instance.
Definition: element.cpp:26
Arena
This class represents the Arena of the game.
Definition: arena.h:36
QString
Element::m_imageId
QString m_imageId
The Id of the Element.
Definition: element.h:57
Granatier::Element::Type
Type
Definition: granatierglobals.h:89
Element::getY
qreal getY() const
Gets the Element y-coordinate.
Definition: element.cpp:51
Element::m_yInit
qreal m_yInit
The Element initial y-coordinate.
Definition: element.h:45
Player
This class represents the main character of the game.
Definition: player.h:33
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