From 591ecc2d7ecb0b41144be9b64c09801ac0a28131 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Sun, 19 Aug 2012 22:10:07 +0200 Subject: [PATCH] run monsters' attack animation --- src/battle/BattleState.cpp | 9 ++++++++- src/battle/states/PerformAttacks.cpp | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 7ea17d8..b934039 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -420,7 +420,14 @@ void BattleState::RenderBackground(SDL_Surface *screen, const Vector &offse void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) { for (vector::size_type i(0), end(monsters.size()); i < end; ++i) { if (MonsterPositionOccupied(i)) { - monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset); + // TODO: better solution for running animations + if (monsters[i].AttackAnimation() && monsters[i].AttackAnimation()->Running()) { + monsters[i].AttackAnimation()->DrawCenter(screen, monsterPositions[i] + offset); + } else if (monsters[i].SpellAnimation() && monsters[i].SpellAnimation()->Running()) { + monsters[i].SpellAnimation()->DrawCenter(screen, monsterPositions[i] + offset); + } else { + monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset); + } } } } diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 9a81e00..86d7a7c 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -71,9 +71,9 @@ void PerformAttacks::HandleEvents(const Input &input) { battle->CalculateDamage(); if (battle->CurrentAttack().isMonster) { - const Monster &monster(battle->MonsterAt(battle->CurrentAttack().index)); + Monster &monster(battle->MonsterAt(battle->CurrentAttack().index)); titleBarText = monster.Name(); - moveAnimation = 0; + moveAnimation = monster.AttackAnimation(); } else { Hero &hero(battle->HeroAt(battle->CurrentAttack().index)); const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index)); -- 2.39.2