File indexing completed on 2024-04-21 04:04:45

0001 /***************************************************************************
0002                           infantrysprite.cpp  -  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 #include "infantrysprite.h"
0024 #include "skinSpritesData.h"
0025 
0026 #include "GameLogic/country.h"
0027 
0028 namespace Ksirk {
0029 
0030 InfantrySprite::InfantrySprite(double zoom,
0031                               BackGnd* aBackGnd,
0032                               unsigned int visibility) :
0033                               ArmySprite(
0034         "infantry",
0035         Sprites::SkinSpritesData::single().intData("infantry-width"),
0036         Sprites::SkinSpritesData::single().intData("infantry-height"),
0037         Sprites::SkinSpritesData::single().intData("infantry-frames"),
0038         Sprites::SkinSpritesData::single().intData("infantry-versions"),
0039         zoom, aBackGnd, visibility)
0040 {
0041 }
0042 
0043 
0044   InfantrySprite::InfantrySprite(const QString &svgid,
0045                                   unsigned int width,
0046                                   unsigned int height,
0047                                   unsigned int nbFrames,
0048                                   unsigned int nbDirs,
0049                                   double zoom,
0050                                   BackGnd* aBackGnd,
0051                                   unsigned int visibility) :
0052                                   ArmySprite(svgid, width, height, nbFrames, nbDirs, zoom, aBackGnd, visibility)
0053 {
0054 }
0055 
0056 /**
0057   * This function chooses the approach mode of an infantry sprite towards its
0058   * destination:
0059   * if the distance between the origin and the destination is higher than half
0060   * the size of the map and if the origin and destination countries comunicate,
0061   * then the sprite should choose an approach by left or right, through the
0062   * edge of the map.
0063   */
0064 void InfantrySprite::setupTravel(
0065     GameLogic::Country* src, 
0066     GameLogic::Country* dest, 
0067     const QPointF* dpi)
0068 {
0069   if (dpi ==nullptr) 
0070   {
0071     AnimSprite::setupTravel(src, dest, src->pointInfantry()*m_zoom, dest-> pointInfantry()*m_zoom);
0072   }
0073   else 
0074   {
0075     AnimSprite::setupTravel(src, dest, src->pointInfantry()*m_zoom, *dpi);
0076   }
0077 }
0078 
0079 }