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