1 /*************************************************************************** 2 infantrysprite.h - description 3 ------------------- 4 begin : 5 copyright : (C) 2003-2007 by Gael de Chalendar 6 email : kleag@free.fr 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either either version 2 14 of the License, or (at your option) any later version.of the License, or * 15 * (at your option) any later version. * 16 * * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 20 * 02110-1301, USA 21 ***************************************************************************/ 22 23 #ifndef KSIRKINFANTRYSPRITE_H 24 #define KSIRKINFANTRYSPRITE_H 25 26 #include "armysprite.h" 27 28 namespace Ksirk { 29 30 namespace GameLogic 31 { 32 class Country; 33 } 34 35 /** 36 * An InfantrySprite is an army sprite that represents 1 army 37 * @author Gaël de Chalendar 38 */ 39 class InfantrySprite : public ArmySprite 40 { 41 public: 42 /** 43 * This simplified constructor allows to create a new @ref InfantrySprite with 44 * default values for svg pool id and skin elements names 45 * @param zoom The current zoom factor 46 * @param aBackGnd The background giving info about the world geometry and 47 * access to the underlying QGraphicsScene 48 * @param visibility Measures how much this sprite is visible. It gives its 49 * Z value on the graphics scene. 50 */ 51 InfantrySprite(double zoom, 52 BackGnd* aBackGnd, 53 unsigned int visibility = 200); 54 55 /** 56 * This constructor allows to create a new @ref AnimSprite whose images are 57 * taken from the given file name with the given number of frames and 58 * number of look directions 59 * @param svgid The id of the SVG element from which to load images 60 * @param aBackGnd The background giving info about the world geometry and 61 * access to the underlying QGraphicsScene 62 * @param nbFrames The number of different frames in this sprite animation, 63 * thus the number of columns in the sprite image 64 * @param nbDirs The number of different views on the sprite, 65 * thus the number of rows in the sprite image 66 * @param visibility Measures how much this sprite is visible. It gives its 67 * Z value on the graphics scene. 68 */ 69 InfantrySprite(const QString &svgid, 70 unsigned int width, 71 unsigned int height, 72 unsigned int nbFrames, 73 unsigned int nbDirs, 74 double zoom, 75 BackGnd* aBackGnd, 76 unsigned int visibility=200); 77 78 /** The default destructor */ ~InfantrySprite()79 ~InfantrySprite() override {} 80 81 /** 82 * This function chooses the approach mode of an infantry sprite towards its 83 * destination: 84 * if the distance between the origin and the destination is higher than half 85 * the size of the map and if the origin and destination countries comunicate, 86 * then the sprite should choose an approach by left or right, through the 87 * edge of the map. 88 */ 89 void setupTravel(GameLogic::Country* src, GameLogic::Country* dest, 90 const QPointF* dpi=0) override; 91 92 /** 93 * Gets the number of armies represented by an infantry: 1 94 * @return the number of armies represented by an infantry: 1 95 */ nbArmies()96 inline unsigned int nbArmies() const override {return m_nbArmies;} 97 98 private: 99 static const unsigned int m_nbArmies = 1; 100 }; 101 102 } 103 104 #endif 105