• 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
characteritem.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 "characteritem.h"
20 #include "character.h"
21 
22 #include <KGameRenderer>
23 
24 CharacterItem::CharacterItem(Character* p_model, KGameRenderer* renderer) : ElementItem (p_model, renderer)
25 {
26  m_renderer = renderer;
27  connect(p_model, SIGNAL(dead()), this, SLOT(setDead()));
28 }
29 
30 CharacterItem::~CharacterItem()
31 {
32 }
33 
34 QPainterPath CharacterItem::shape() const
35 {
36  QPainterPath path;
37  // Temporary variable to keep the boundingRect available
38  QRectF rect = boundingRect();
39 
40  // Calculation of the shape
41  QRectF shapeRect = QRectF( rect.x()+rect.width()/8, rect.y()+rect.height()/8, rect.width()*3.0/4.0, rect.height()*3.0/4.0 );
42  path.addEllipse(shapeRect);
43  return path;
44 }
45 
46 void CharacterItem::update(qreal p_x, qreal p_y)
47 {
48  // Compute the top-right coordinates of the item
49  qreal x = p_x - m_itemSizeSet.width() / 2;
50  qreal y = p_y - m_itemSizeSet.height() / 2;
51  // Updates the view coordinates
52  setPos(x, y);
53 }
54 
55 void CharacterItem::setDead()
56 {
57 }
58 
QPainterPath::addEllipse
void addEllipse(const QRectF &boundingRectangle)
character.h
CharacterItem::update
virtual void update(qreal p_x, qreal p_y)
Updates the CharacterItem coordinates.
Definition: characteritem.cpp:46
QSize::width
int width() const
CharacterItem::setDead
virtual void setDead()
Sets the character dead.
Definition: characteritem.cpp:55
QRectF::x
qreal x() const
QRectF::y
qreal y() const
Character
This class describes the common characteristics and behaviour of the game characters (Players)...
Definition: character.h:31
CharacterItem::shape
QPainterPath shape() const
Overrides the default shape function to make it a small circle This function is used to determinate c...
Definition: characteritem.cpp:34
ElementItem::m_itemSizeSet
QSize m_itemSizeSet
Definition: elementitem.h:44
characteritem.h
ElementItem
This class is the graphical representation of a game Element.
Definition: elementitem.h:30
CharacterItem::~CharacterItem
~CharacterItem()
Deletes the CharacterItem instance.
Definition: characteritem.cpp:30
CharacterItem::m_renderer
KGameRenderer * m_renderer
Shared renderer for the player frames.
Definition: characteritem.h:36
QPainterPath
QRectF::width
qreal width() const
CharacterItem::CharacterItem
CharacterItem(Character *p_model, KGameRenderer *renderer)
Creates a new CharacterItem instance.
Definition: characteritem.cpp:24
QRectF
QSize::height
int height() const
QRectF::height
qreal height() const
QObject::connect
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
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