From: Daniel Karbach Date: Mon, 20 Aug 2012 21:56:22 +0000 (+0200) Subject: put animations in place X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=56f6bddd8f4616c8c5ea564f60c5a3dbc7dafd82;p=l2e.git put animations in place --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index bf2d2c1..fd4be08 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -449,10 +449,8 @@ void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) for (vector::size_type i(0), end(monsters.size()); i < end; ++i) { if (MonsterPositionOccupied(i)) { // 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); + if (monsters[i].GetAnimation().Running()) { + monsters[i].GetAnimation().DrawCenter(screen, monsterPositions[i] + offset); } else { monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset); } @@ -463,10 +461,8 @@ void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) void BattleState::RenderHeroes(SDL_Surface *screen, const Vector &offset) { assert(screen); for (int i(0); i < numHeroes; ++i) { - if (heroes[i].AttackAnimation() && heroes[i].AttackAnimation()->Running()) { - heroes[i].AttackAnimation()->DrawCenter(screen, heroesPositions[i] + offset); - } else if (heroes[i].SpellAnimation() && heroes[i].SpellAnimation()->Running()) { - heroes[i].SpellAnimation()->DrawCenter(screen, heroesPositions[i] + offset); + if (heroes[i].GetAnimation().Running()) { + heroes[i].GetAnimation().DrawCenter(screen, heroesPositions[i] + offset); } else { int row(heroes[i].Health() > 0 ? 0 : 2); heroes[i].Sprite()->DrawCenter(screen, heroesPositions[i] + offset, 1, row); diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 15c4feb..05227e6 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -121,11 +121,17 @@ void PerformAttacks::HandleEvents(const Input &input) { moveAnimation.Clear(); break; } - hero.SetAnimation(moveAnimation); } if (titleBarText) titleBarTimer = GraphicsTimers().StartCountdown(850); - if (moveAnimation.Valid()) moveAnimation.Start(*this); + if (moveAnimation.Valid()) { + moveAnimation.Start(*this); + if (battle->CurrentAttack().isMonster) { + battle->MonsterAt(battle->CurrentAttack().index).SetAnimation(moveAnimation); + } else { + battle->HeroAt(battle->CurrentAttack().index).SetAnimation(moveAnimation); + } + } if (targetAnimation.Valid()) { targetAnimationTimer = GraphicsTimers().StartCountdown(150); } else {