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