From: Daniel Karbach Date: Sat, 11 Aug 2012 19:16:33 +0000 (+0200) Subject: handle dead hero in BattleState X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=c484a03fda545a6803be63aa0a35f23c26cc8e2f;p=l2e.git handle dead hero in BattleState --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 6fac152..6aeaae5 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -51,6 +51,13 @@ void BattleState::AddHero(const Hero &h) { ++numHeroes; } +void BattleState::NextHero() { + ++activeHero; + while (activeHero < numHeroes && heroes[activeHero].Health() == 0) { + ++activeHero; + } +} + void BattleState::SwapHeroes(int lhs, int rhs) { if (lhs < 0 || lhs >= numHeroes || rhs < 0 || rhs >= numHeroes || lhs == rhs) return; std::swap(heroes[lhs], heroes[rhs]); @@ -259,7 +266,8 @@ void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) void BattleState::RenderHeroes(SDL_Surface *screen, const Vector &offset) { for (int i(0); i < numHeroes; ++i) { - heroes[i].Sprite()->DrawCenterBottom(screen, heroesPositions[i] + offset, 0, 1); + int row(heroes[i].Health() > 0 ? 0 : 2); + heroes[i].Sprite()->DrawCenterBottom(screen, heroesPositions[i] + offset, 1, row); } } diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index a901c63..b491af8 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -84,8 +84,7 @@ public: graphics::Menu &GetItemMenu() { return itemMenu; } const graphics::Menu &GetItemMenu() const { return itemMenu; } - bool HasMoreHeroes() const { return activeHero < numHeroes; } - void NextHero() { ++activeHero; } + void NextHero(); bool BeforeFirstHero() const { return activeHero < 0; } void PreviousHero() { --activeHero; } void SwapHeroes(int lhs, int rhs); diff --git a/test-data/dekar.png b/test-data/dekar.png index 3771245..5671f49 100644 Binary files a/test-data/dekar.png and b/test-data/dekar.png differ diff --git a/test-data/guy.png b/test-data/guy.png index c6fa7f5..a292ec1 100644 Binary files a/test-data/guy.png and b/test-data/guy.png differ diff --git a/test-data/maxim.png b/test-data/maxim.png index e7e20bd..bb195c1 100644 Binary files a/test-data/maxim.png and b/test-data/maxim.png differ diff --git a/test-data/selan.png b/test-data/selan.png index 8b46f88..7da4e59 100644 Binary files a/test-data/selan.png and b/test-data/selan.png differ