1 /***************************************************************************
2                           infantrysprite.cpp  -  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 #include "infantrysprite.h"
24 #include "skinSpritesData.h"
25 
26 #include "GameLogic/country.h"
27 
28 namespace Ksirk {
29 
InfantrySprite(double zoom,BackGnd * aBackGnd,unsigned int visibility)30 InfantrySprite::InfantrySprite(double zoom,
31                               BackGnd* aBackGnd,
32                               unsigned int visibility) :
33                               ArmySprite(
34         "infantry",
35         Sprites::SkinSpritesData::single().intData("infantry-width"),
36         Sprites::SkinSpritesData::single().intData("infantry-height"),
37         Sprites::SkinSpritesData::single().intData("infantry-frames"),
38         Sprites::SkinSpritesData::single().intData("infantry-versions"),
39         zoom, aBackGnd, visibility)
40 {
41 }
42 
43 
InfantrySprite(const QString & svgid,unsigned int width,unsigned int height,unsigned int nbFrames,unsigned int nbDirs,double zoom,BackGnd * aBackGnd,unsigned int visibility)44   InfantrySprite::InfantrySprite(const QString &svgid,
45                                   unsigned int width,
46                                   unsigned int height,
47                                   unsigned int nbFrames,
48                                   unsigned int nbDirs,
49                                   double zoom,
50                                   BackGnd* aBackGnd,
51                                   unsigned int visibility) :
52                                   ArmySprite(svgid, width, height, nbFrames, nbDirs, zoom, aBackGnd, visibility)
53 {
54 }
55 
56 /**
57   * This function chooses the approach mode of an infantry sprite towards its
58   * destination:
59   * if the distance between the origin and the destination is higher than half
60   * the size of the map and if the origin and destination countries comunicate,
61   * then the sprite should choose an approach by left or right, through the
62   * edge of the map.
63   */
setupTravel(GameLogic::Country * src,GameLogic::Country * dest,const QPointF * dpi)64 void InfantrySprite::setupTravel(
65     GameLogic::Country* src,
66     GameLogic::Country* dest,
67     const QPointF* dpi)
68 {
69   if (dpi ==0)
70   {
71     AnimSprite::setupTravel(src, dest, src->pointInfantry()*m_zoom, dest-> pointInfantry()*m_zoom);
72   }
73   else
74   {
75     AnimSprite::setupTravel(src, dest, src->pointInfantry()*m_zoom, *dpi);
76   }
77 }
78 
79 }
80