File indexing completed on 2024-02-25 04:07:17

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 #ifndef CHARACTERITEM_H
0009 #define CHARACTERITEM_H
0010 
0011 #include "elementitem.h"
0012 
0013 class Character;
0014 class KGameRenderer;
0015 
0016 /**
0017  * @brief This class is the graphical representation of a Character.
0018  */
0019 class CharacterItem : public ElementItem {
0020 
0021 Q_OBJECT
0022 
0023 protected:
0024     /** Shared renderer for the player frames */
0025     KGameRenderer* m_renderer;
0026 
0027 public:
0028 
0029     /**
0030       * Creates a new CharacterItem instance.
0031       * @param p_model the Character model
0032       * @param renderer the KGameRenderer
0033       */
0034     CharacterItem(Character* p_model, KGameRenderer* renderer);
0035 
0036     /**
0037       * Deletes the CharacterItem instance.
0038       */
0039     ~CharacterItem() override;
0040 
0041     /**
0042       * Overrides the default shape function to make it a small circle
0043       * This function is used to determinate collision between items
0044       * @return QPainterPath the new shape of the Character
0045       */
0046     QPainterPath shape() const override;
0047 
0048 public Q_SLOTS:
0049 
0050     /**
0051       * Updates the CharacterItem coordinates.
0052       * @param p_x the new x-coordinate
0053       * @param p_y the new y-coordinate
0054       */
0055     void update(qreal p_x, qreal p_y) override;
0056 
0057     /**
0058       * Sets the character dead.
0059       */
0060     virtual void setDead();
0061 };
0062 
0063 #endif
0064