Warning, file /games/kapman/src/element.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2007-2008 Thomas Gallinari <tg8187@yahoo.fr>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef ELEMENT_H
0008 #define ELEMENT_H
0009 
0010 #include <QObject>
0011 
0012 #include "maze.h"
0013 
0014 class Kapman;
0015 
0016 /**
0017  * @brief This class describes the common characteristics and behaviour of any game Element (character or item).
0018  */
0019 class Element : public QObject
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     /** The Element possible types */
0025     enum Type { KAPMAN = 0, GHOST = 1, PILL = 2, ENERGYZER = 3, BONUS = 4 };
0026 
0027 protected:
0028     /** The Element type */
0029     Type m_type;
0030 
0031     /** The Element initial x-coordinate */
0032     qreal m_xInit;
0033 
0034     /** The Element initial y-coordinate */
0035     qreal m_yInit;
0036 
0037     /** The Element current x-coordinate */
0038     qreal m_x;
0039 
0040     /** The Element current y-coordinate */
0041     qreal m_y;
0042 
0043     /** The Maze the Element is on */
0044     Maze *m_maze;
0045 
0046     /** The Id of the Element */
0047     QString m_imageId;
0048 
0049     /** Points won when the Element is eaten */
0050     int m_points;
0051 
0052 public:
0053     /**
0054      * Creates a new Element instance.
0055      * @param p_x the initial x-coordinate
0056      * @param p_y the initial y-coordinate
0057      * @param p_maze the Maze the Element is on
0058      */
0059     Element(qreal p_x, qreal p_y, Maze *p_maze);
0060 
0061     /**
0062      * Deletes the Element instance.
0063      */
0064     ~Element() override;
0065 
0066     /**
0067      * Computes an action on a collision with the Kapman.
0068      * @param p_kapman the instance of Kapman which collides with the Element
0069      */
0070     virtual void doActionOnCollision(Kapman *p_kapman);
0071 
0072     /**
0073      * Gets the path to the Element image.
0074      * @return the path to the Element image
0075      */
0076     QString getImageId() const;
0077 
0078     /**
0079      * Gets the value of the Element.
0080      * @return the points won when the Element is eaten
0081      */
0082     int getPoints() const;
0083 
0084     /**
0085      * Gets the type of the Element.
0086      * @return the Element type
0087      */
0088     Element::Type getType() const;
0089 
0090     /**
0091      * Sets the Element image.
0092      * @param p_imageId the image to set
0093      */
0094     void setImageId(const QString &p_imageId);
0095 
0096     /**
0097      * Gets the Element x-coordinate.
0098      * @return the x-coordinate
0099      */
0100     qreal getX() const;
0101 
0102     /**
0103      * Gets the Element y-coordinate.
0104      * @return the y-coordinate
0105      */
0106     qreal getY() const;
0107 
0108     /**
0109      * Sets the Element x-coordinate to the given value
0110      * @param p_x the x-coordinate to set
0111      */
0112     void setX(qreal p_x);
0113 
0114     /**
0115      * Sets the Element y-coordinate to the given value
0116      * @param p_y the y-coordinate to set
0117      */
0118     void setY(qreal p_y);
0119 
0120     /**
0121      * Initializes Element x-coordinate and y-coordinate with
0122      * initial values
0123      */
0124     void initCoordinate();
0125 
0126 Q_SIGNALS:
0127 
0128     /**
0129      * Emitted on Element move.
0130      * @param p_x the new x-coordinate
0131      * @param p_y the new y-coordinate
0132      */
0133     void moved(qreal p_x, qreal p_y);
0134 };
0135 
0136 #endif