From 8a6225176cd0946363ac2d8219d54a13009de675 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 14 Aug 2012 22:30:05 +0200 Subject: [PATCH] changed battle positions from bottom-center to center --- src/battle/BattleState.cpp | 8 ++++---- src/battle/HeroTag.cpp | 6 +++--- src/battle/states/SelectTarget.cpp | 13 +++++-------- src/main.cpp | 16 ++++++++-------- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index db221b4..1a4f726 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -284,19 +284,19 @@ 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) { - monsters[i].Sprite()->DrawCenterBottom(screen, monsterPositions[i] + offset); + monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset); } } void BattleState::RenderHeroes(SDL_Surface *screen, const Vector &offset) { for (int i(0); i < numHeroes; ++i) { if (heroes[i].AttackAnimation() && heroes[i].AttackAnimation()->Running()) { - heroes[i].AttackAnimation()->DrawCenterBottom(screen, heroesPositions[i] + offset); + heroes[i].AttackAnimation()->DrawCenter(screen, heroesPositions[i] + offset); } else if (heroes[i].SpellAnimation() && heroes[i].SpellAnimation()->Running()) { - heroes[i].SpellAnimation()->DrawCenterBottom(screen, heroesPositions[i] + offset); + heroes[i].SpellAnimation()->DrawCenter(screen, heroesPositions[i] + offset); } else { int row(heroes[i].Health() > 0 ? 0 : 2); - heroes[i].Sprite()->DrawCenterBottom(screen, heroesPositions[i] + offset, 1, row); + heroes[i].Sprite()->DrawCenter(screen, heroesPositions[i] + offset, 1, row); } } } diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index d50b413..f6682df 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -93,13 +93,13 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point posi } // hero - HeroSprite()->Draw(screen, position + HeroOffset(), 0, battle->HeroAt(index).Health() > 0 ? 0 : 2); + HeroSprite()->DrawCenter(screen, position + HeroOffset(), 0, battle->HeroAt(index).Health() > 0 ? 0 : 2); } Vector HeroTag::HeroOffset() const { return Vector( - (index % 2) ? battle->Res().normalFont->CharWidth() : 10 * battle->Res().normalFont->CharWidth(), - battle->Res().normalFont->CharWidth()); + ((index % 2) ? battle->Res().normalFont->CharWidth() : 10 * battle->Res().normalFont->CharWidth()) + HeroSprite()->Width() / 2, + battle->Res().normalFont->CharWidth() + HeroSprite()->Height() / 2); } } diff --git a/src/battle/states/SelectTarget.cpp b/src/battle/states/SelectTarget.cpp index 8fe31cd..2583857 100644 --- a/src/battle/states/SelectTarget.cpp +++ b/src/battle/states/SelectTarget.cpp @@ -90,9 +90,9 @@ void SelectTarget::Render(SDL_Surface *screen) { void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector &offset) { // TODO: this should be related to the enemy's width - // offset the cursor by 1/8th to the left and bottom - Vector cursorOffset(cursorIcon->Width() / -8, cursorIcon->Height() / 8); - Vector indicatorOffset(0, 0); + Vector cursorOffset(cursorIcon->Width() / -2, cursorIcon->Height()); + // offset the indicator by 1/8th to the right and top + Vector indicatorOffset(cursorOffset + Vector(cursorIcon->Width() / 8, cursorIcon->Height() / -8)); vector > positions; if (selection->TargetsEnemies()) { for (vector >::const_iterator i(battle->MonsterPositions().begin()), end(battle->MonsterPositions().end()); i != end; ++i) { @@ -100,16 +100,13 @@ void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::VectorNumHeroes()); i < end; ++i) { - Vector positionCorrection(cursorIcon->Width() / 2, battle->HeroTagAt(i).HeroSprite()->Height() - cursorIcon->Height() / 2); - // indicator offsets are inverted for heroes - positionCorrection -= cursorOffset; - positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset() + positionCorrection); + positions.push_back(battle->HeroTagPositionAt(i) + battle->HeroTagAt(i).HeroOffset()); } } if (flipFlop) { for (vector >::size_type i(0); i < positions.size(); ++i) { if (selection->IsSelected(i)) { - cursorIcon->DrawTopRight(screen, positions[i] + offset); + cursorIcon->DrawTopRight(screen, positions[i] + indicatorOffset + offset); } } } diff --git a/src/main.cpp b/src/main.cpp index c4dabad..909cbd4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,15 +74,15 @@ int main(int argc, char **argv) { // temporary test data SDL_Surface *bg(IMG_Load("test-data/battle-bg.png")); PartyLayout monstersLayout; - monstersLayout.AddPosition(Point(88, 104)); - monstersLayout.AddPosition(Point(128, 104)); - monstersLayout.AddPosition(Point(168, 104)); - monstersLayout.AddPosition(Point(208, 104)); + monstersLayout.AddPosition(Point(88, 88)); + monstersLayout.AddPosition(Point(128, 88)); + monstersLayout.AddPosition(Point(168, 88)); + monstersLayout.AddPosition(Point(208, 88)); PartyLayout heroesLayout; - heroesLayout.AddPosition(Point(48, 152)); - heroesLayout.AddPosition(Point(128, 152)); - heroesLayout.AddPosition(Point(80, 168)); - heroesLayout.AddPosition(Point(160, 168)); + heroesLayout.AddPosition(Point(48, 136)); + heroesLayout.AddPosition(Point(128, 136)); + heroesLayout.AddPosition(Point(80, 152)); + heroesLayout.AddPosition(Point(160, 152)); SDL_Surface *monsterImg(IMG_Load("test-data/monster.png")); Sprite dummySprite(monsterImg, 64, 64); -- 2.39.2