File indexing completed on 2024-05-05 04:02:04
0001 /* 0002 SPDX-FileCopyrightText: 2007-2008 John-Paul Stanford <jp@stanwood.org.uk> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef BUILDING_H 0008 #define BUILDING_H 0009 0010 // Qt 0011 #include <QList> 0012 #include <QRect> 0013 #include <QSize> 0014 0015 class KGameRenderedItem; 0016 class KGameRenderer; 0017 class BomberBoard; 0018 0019 /** 0020 * This class is used to represent the Building game objects. Each buildings are made up for 0021 * building tiles which are placed on the game canvas. 0022 */ 0023 class Building 0024 { 0025 public: 0026 static const unsigned int BUILD_BASE_LOCATION; 0027 Building(KGameRenderer * renderer, BomberBoard * board, unsigned int position, 0028 unsigned int height); 0029 ~Building(); 0030 0031 /** 0032 * Set the height of the building 0033 * \param height The new height of the building 0034 */ 0035 void setHeight(unsigned int height); 0036 0037 /** 0038 * Get the height of the building 0039 * \return The height of the building 0040 */ 0041 unsigned int height() const; 0042 0043 /** 0044 * Sets width and height of plane. 0045 */ 0046 void resize(const QSize & tileSize); 0047 0048 /** 0049 * Sets building's current frame 0050 */ 0051 void setFrame(unsigned int frame); 0052 0053 /** 0054 * Show the building item on the game scene 0055 */ 0056 void show(); 0057 0058 /** 0059 * Get the bounding rectangle of the building 0060 * \return the Bounding rectangle of the building 0061 */ 0062 QRectF boundingRect() const; 0063 0064 /** 0065 * This is used to destory the top of the building 0066 */ 0067 void destoryTop(); 0068 0069 /** 0070 * Return the position of the building 0071 * \return The position of the building 0072 */ 0073 QPointF position() const; 0074 0075 private: 0076 /** 0077 * Setup the tiles that make up the building 0078 */ 0079 void setupBuildingTiles(); 0080 0081 /** 0082 * Used to create a new building tile 0083 * \param pixmap The pixmap the building tile should be created with 0084 * \return The new created building tile 0085 */ 0086 KGameRenderedItem * createBuildingTile(const QString & pixmap); 0087 0088 unsigned int m_height; 0089 QRectF m_boundingRect; 0090 KGameRenderer * m_renderer; 0091 BomberBoard * m_board; 0092 QList<KGameRenderedItem *> m_buildingTiles; 0093 0094 qreal m_xPos; 0095 }; 0096 0097 #endif