1 /***************************************************************************
2                           cannonsprite.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 KSIRKCANNONSPRITE_H
24 #define KSIRKCANNONSPRITE_H
25 
26 #include "armysprite.h"
27 
28 namespace Ksirk {
29 
30 namespace GameLogic
31 {
32   class Country;
33 }
34 
35 /**
36   * A CannonSprite is an army sprite that represents ten armies
37   * @author Gaël de Chalendar
38   */
39 class CannonSprite : public ArmySprite
40 {
41 public:
42   /**
43     * This simplified constructor allows to create a new @ref CannonSpritewith
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   CannonSprite(double zoom,
52                 BackGnd* aBackGnd,
53                 unsigned int visibility = 200);
54 
55   /**
56     * This constructor allows to create a new @ref CannonSprite whose images are
57     * taken from the given svg pool element 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 nbFrames The number of different frames in this sprite animation,
61     * thus the number of columns in the sprite image
62     * @param nbDirs The number of different views on the sprite,
63     * thus the number of rows in the sprite image
64     * @param zoom The current zoom factor
65     * @param aBackGnd The background giving info about the world geometry and
66     * access to the underlying QGraphicsScene
67     * @param visibility Measures how much this sprite is visible. It gives its
68     * Z value on the graphics scene.
69     */
70   CannonSprite(const QString &svgid,
71                 unsigned int width,
72                 unsigned int height,
73                 unsigned int nbFrames,
74                 unsigned int nbDirs,
75                 double zoom,
76                 BackGnd* aBackGnd,
77                 unsigned int visibility = 200);
78 
79   /** The default destructor */
~CannonSprite()80   ~CannonSprite() override {}
81 
82   /**
83     * Gets the number of armies represented by a cannon: 10
84     * @return the number of armies represented by a cannon: 10
85     */
nbArmies()86   inline unsigned int nbArmies() const override {return m_nbArmies;}
87 
88   /**
89     * Overloads the AnimSprite method. This virtual function chooses the
90     * approach mode of a sprite towards its destination:
91     * if the distance between the origin and the destination is higher than half
92     * the size of the map and if the origin and destination countries
93     * comunicate, then the sprite should choose an approach by left or right,
94     * through the edge of the map.
95     * @param src The source country of the journey
96     * @param dest The destination country of the journey
97     * @param dpi The point where the army should go. 0 if should use the
98     * default (cannon point)
99     */
100   void setupTravel(GameLogic::Country* src, GameLogic::Country* dest,
101     const QPointF* dpi=0) override;
102 
103 private:
104   static const unsigned int m_nbArmies = 10;
105 };
106 
107 }
108 
109 #endif
110