]> git.localhorst.tv Git - l2e.git/commitdiff
changed battle positions from bottom-center to center
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 14 Aug 2012 20:30:05 +0000 (22:30 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 14 Aug 2012 20:30:05 +0000 (22:30 +0200)
src/battle/BattleState.cpp
src/battle/HeroTag.cpp
src/battle/states/SelectTarget.cpp
src/main.cpp

index db221b43324293f29d1fe3e8df0303c2878f6945..1a4f726de656c7a5c561ac01315d7472c898ace9 100644 (file)
@@ -284,19 +284,19 @@ void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offse
 
 void BattleState::RenderMonsters(SDL_Surface *screen, const Vector<int> &offset) {
        for (vector<Monster>::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<int> &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);
                }
        }
 }
index d50b4132d85860f7556041794eac260793c92480..f6682df4e5da9df1b424d65ceb3ca7ee07d96d71 100644 (file)
@@ -93,13 +93,13 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> 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<int> HeroTag::HeroOffset() const {
        return Vector<int>(
-                       (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);
 }
 
 }
index 8fe31cd60dad1e1953c3460d86f4998870158969..25838571162f0aa45e58ff88012063ce0024ade6 100644 (file)
@@ -90,9 +90,9 @@ void SelectTarget::Render(SDL_Surface *screen) {
 
 void SelectTarget::RenderCursors(SDL_Surface *screen, const geometry::Vector<int> &offset) {
        // TODO: this should be related to the enemy's width
-       // offset the cursor by 1/8th to the left and bottom
-       Vector<int> cursorOffset(cursorIcon->Width() / -8, cursorIcon->Height() / 8);
-       Vector<int> indicatorOffset(0, 0);
+       Vector<int> cursorOffset(cursorIcon->Width() / -2, cursorIcon->Height());
+       // offset the indicator by 1/8th to the right and top
+       Vector<int> indicatorOffset(cursorOffset + Vector<int>(cursorIcon->Width() / 8, cursorIcon->Height() / -8));
        vector<Point<int> > positions;
        if (selection->TargetsEnemies()) {
                for (vector<Point<int> >::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::Vector<int
                }
        } else {
                for (int i(0), end(battle->NumHeroes()); i < end; ++i) {
-                       Vector<int> 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<Point<int> >::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);
                        }
                }
        }
index c4dabad0bf0c44dc45fc9d8a08ef25fe056beb71..909cbd4be04c6292f990c661fd4d5dd265762c09 100644 (file)
@@ -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<Uint8>(88, 104));
-               monstersLayout.AddPosition(Point<Uint8>(128, 104));
-               monstersLayout.AddPosition(Point<Uint8>(168, 104));
-               monstersLayout.AddPosition(Point<Uint8>(208, 104));
+               monstersLayout.AddPosition(Point<Uint8>(88, 88));
+               monstersLayout.AddPosition(Point<Uint8>(128, 88));
+               monstersLayout.AddPosition(Point<Uint8>(168, 88));
+               monstersLayout.AddPosition(Point<Uint8>(208, 88));
                PartyLayout heroesLayout;
-               heroesLayout.AddPosition(Point<Uint8>(48, 152));
-               heroesLayout.AddPosition(Point<Uint8>(128, 152));
-               heroesLayout.AddPosition(Point<Uint8>(80, 168));
-               heroesLayout.AddPosition(Point<Uint8>(160, 168));
+               heroesLayout.AddPosition(Point<Uint8>(48, 136));
+               heroesLayout.AddPosition(Point<Uint8>(128, 136));
+               heroesLayout.AddPosition(Point<Uint8>(80, 152));
+               heroesLayout.AddPosition(Point<Uint8>(160, 152));
 
                SDL_Surface *monsterImg(IMG_Load("test-data/monster.png"));
                Sprite dummySprite(monsterImg, 64, 64);