mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-28 08:48:48 +02:00
* corrected stack death animation
This commit is contained in:
parent
dc73072ba4
commit
329eab2f6a
@ -1169,27 +1169,16 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
|
||||
}
|
||||
}
|
||||
//initializing
|
||||
std::map<int, int> animLengths;
|
||||
std::map<int, int> increments;
|
||||
int maxLen = 0;
|
||||
for(size_t g=0; g<attackedInfos.size(); ++g)
|
||||
{
|
||||
int animLen;
|
||||
if(attackedInfos[g].killed)
|
||||
{
|
||||
creAnims[attackedInfos[g].ID]->setType(5); //death
|
||||
animLen = creAnims[attackedInfos[g].ID]->framesInGroup(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
creAnims[attackedInfos[g].ID]->setType(3); //getting hit
|
||||
animLen = creAnims[attackedInfos[g].ID]->framesInGroup(3);
|
||||
}
|
||||
animLengths.insert(std::make_pair(attackedInfos[g].ID, animLen));
|
||||
increments.insert(std::make_pair(attackedInfos[g].ID, 0));
|
||||
if(animLen > maxLen)
|
||||
{
|
||||
maxLen = animLen;
|
||||
}
|
||||
}
|
||||
//main showing loop
|
||||
@ -1201,18 +1190,17 @@ void CBattleInterface::stacksAreAttacked(std::vector<CBattleInterface::SStackAtt
|
||||
SDL_framerateDelay(LOCPLINT->mainFPSmng);
|
||||
for(size_t g=0; g<attackedInfos.size(); ++g)
|
||||
{
|
||||
if((animCount+1)%(4/animSpeed)==0 && increments[attackedInfos[g].ID]<animLengths[attackedInfos[g].ID])
|
||||
if((animCount+1)%(4/animSpeed)==0 && !creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
|
||||
{
|
||||
creAnims[attackedInfos[g].ID]->incrementFrame();
|
||||
++(increments[attackedInfos[g].ID]);
|
||||
}
|
||||
if(increments[attackedInfos[g].ID]>=animLengths[attackedInfos[g].ID] && creAnims[attackedInfos[g].ID]->getType() == 3)
|
||||
if(creAnims[attackedInfos[g].ID]->onLastFrameInGroup() && creAnims[attackedInfos[g].ID]->getType() == 3)
|
||||
creAnims[attackedInfos[g].ID]->setType(2);
|
||||
}
|
||||
bool isAnotherOne = false; //if true, there is a stack whose hit/death anim must be continued
|
||||
for(size_t g=0; g<attackedInfos.size(); ++g)
|
||||
{
|
||||
if(increments[attackedInfos[g].ID] < animLengths[attackedInfos[g].ID] - 1)
|
||||
if(!creAnims[attackedInfos[g].ID]->onLastFrameInGroup())
|
||||
{
|
||||
isAnotherOne = true;
|
||||
break;
|
||||
|
@ -137,6 +137,13 @@ int CCreatureAnimation::getFrame() const
|
||||
return curFrame;
|
||||
}
|
||||
|
||||
bool CCreatureAnimation::onLastFrameInGroup()
|
||||
{
|
||||
if(internalFrame == frameGroups[type].size() - 1)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void CCreatureAnimation::playOnce(int type)
|
||||
{
|
||||
setType(type);
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, unsigned char animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next
|
||||
void incrementFrame();
|
||||
int getFrame() const;
|
||||
bool onLastFrameInGroup();
|
||||
|
||||
bool once;
|
||||
void playOnce(int type); //plays once given stage of animation, then resets to 2
|
||||
|
Loading…
Reference in New Issue
Block a user