File indexing completed on 2024-02-18 04:03:24

0001 /*
0002     SPDX-FileCopyrightText: 2009 Mathias Kraus <k.hias@gmx.de>
0003     SPDX-FileCopyrightText: 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "element.h"
0009 
0010 Element::Element(qreal p_x, qreal p_y, Arena* p_arena) : m_xInit(p_x), m_yInit(p_y),  m_arena(p_arena)
0011 {
0012     initCoordinate();
0013 }
0014 
0015 Element::~Element()
0016 = default;
0017 
0018 void Element::doActionOnCollision(Player*)
0019 {
0020     // Do nothing by default : will be redefined within the subclasses
0021 }
0022 
0023 void Element::setArena(Arena* p_arena)
0024 {
0025     m_arena = p_arena;
0026 }
0027 
0028 void Element::setInitialCoordinates (qreal p_x, qreal p_y)
0029 {
0030     m_xInit = p_x;
0031     m_yInit = p_y;
0032 }
0033 
0034 qreal Element::getX() const
0035 {
0036     return m_x;
0037 }
0038 
0039 qreal Element::getY() const
0040 {
0041     return m_y;
0042 }
0043 
0044 void Element::setX(qreal p_x)
0045 {
0046     m_x = p_x;
0047     Q_EMIT moved(m_x, m_y);
0048 }
0049 
0050 void Element::setY(qreal p_y)
0051 {
0052     m_y = p_y;
0053     Q_EMIT moved(m_x, m_y);
0054 }
0055 
0056 Granatier::Element::Type Element::getType() const
0057 {
0058     return m_type;
0059 }
0060 
0061 QString Element::getImageId() const
0062 {
0063     return m_imageId;
0064 }
0065 
0066 void  Element::setImageId(const QString & p_imageId)
0067 {
0068     m_imageId = p_imageId;
0069 }
0070 
0071 void Element::initCoordinate()
0072 {
0073     setX(m_xInit);
0074     setY(m_yInit);
0075 }
0076 
0077 #include "moc_element.cpp"