File indexing completed on 2024-04-28 04:04:30

0001 /***************************************************************************
0002                           cannonsprite.h  -  description
0003                              -------------------
0004     begin                : 
0005     copyright            : (C) 2003-2007 by Gael de Chalendar
0006     email                : kleag@free.fr
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *                                                                         *
0011  *   This program is free software; you can redistribute it and/or modify  *
0012  *   it under the terms of the GNU General Public License as published by  *
0013  *   the Free Software Foundation; either either version 2
0014    of the License, or (at your option) any later version.of the License, or     *
0015  *   (at your option) any later version.                                   *
0016  *                                                                         *
0017  *   You should have received a copy of the GNU General Public License
0018  *   along with this program; if not, write to the Free Software
0019  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0020  *   02110-1301, USA
0021  ***************************************************************************/
0022 
0023 #ifndef KSIRKCANNONSPRITE_H
0024 #define KSIRKCANNONSPRITE_H
0025 
0026 #include "armysprite.h"
0027 
0028 namespace Ksirk {
0029 
0030 namespace GameLogic
0031 {
0032   class Country;
0033 }
0034 
0035 /**
0036   * A CannonSprite is an army sprite that represents ten armies
0037   * @author Gaƫl de Chalendar
0038   */
0039 class CannonSprite : public ArmySprite
0040 {
0041 public:
0042   /**
0043     * This simplified constructor allows to create a new @ref CannonSpritewith
0044     * default values for svg pool id and skin elements names
0045     * @param zoom The current zoom factor
0046     * @param aBackGnd The background giving info about the world geometry and
0047     * access to the underlying QGraphicsScene
0048     * @param visibility Measures how much this sprite is visible. It gives its
0049     * Z value on the graphics scene.
0050     */
0051   CannonSprite(double zoom,
0052                 BackGnd* aBackGnd,
0053                 unsigned int visibility = 200);
0054 
0055   /**
0056     * This constructor allows to create a new @ref CannonSprite whose images are
0057     * taken from the given svg pool element with the given number of frames and
0058     * number of look directions
0059     * @param svgid The id of the SVG element from which to load images
0060     * @param nbFrames The number of different frames in this sprite animation,
0061     * thus the number of columns in the sprite image
0062     * @param nbDirs The number of different views on the sprite,
0063     * thus the number of rows in the sprite image
0064     * @param zoom The current zoom factor
0065     * @param aBackGnd The background giving info about the world geometry and
0066     * access to the underlying QGraphicsScene
0067     * @param visibility Measures how much this sprite is visible. It gives its
0068     * Z value on the graphics scene.
0069     */
0070   CannonSprite(const QString &svgid,
0071                 unsigned int width,
0072                 unsigned int height,
0073                 unsigned int nbFrames,
0074                 unsigned int nbDirs,
0075                 double zoom,
0076                 BackGnd* aBackGnd,
0077                 unsigned int visibility = 200);
0078 
0079   /** The default destructor */
0080   ~CannonSprite() override {}
0081 
0082   /**
0083     * Gets the number of armies represented by a cannon: 10
0084     * @return the number of armies represented by a cannon: 10
0085     */
0086   inline unsigned int nbArmies() const override {return m_nbArmies;}
0087 
0088   /**
0089     * Overloads the AnimSprite method. This virtual function chooses the 
0090     * approach mode of a sprite towards its destination:
0091     * if the distance between the origin and the destination is higher than half
0092     * the size of the map and if the origin and destination countries 
0093     * comunicate, then the sprite should choose an approach by left or right,
0094     * through the edge of the map.
0095     * @param src The source country of the journey
0096     * @param dest The destination country of the journey
0097     * @param dpi The point where the army should go. 0 if should use the 
0098     * default (cannon point)
0099     */
0100   void setupTravel(GameLogic::Country* src, GameLogic::Country* dest, 
0101     const QPointF* dpi=nullptr) override;
0102 
0103 private:
0104   static const unsigned int m_nbArmies = 10;
0105 };
0106 
0107 }
0108 
0109 #endif