From: Daniel Karbach Date: Tue, 7 Aug 2012 19:25:50 +0000 (+0200) Subject: better positioning of hero tags X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=3ecf76abb280da727806262b4cac3472d94f9c5a;p=l2e.git better positioning of hero tags --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 2b46cac..6cb3b32 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -112,14 +112,14 @@ void BattleState::RenderHeroes(SDL_Surface *screen, const Vector &offset) { } void BattleState::RenderHeroTags(SDL_Surface *screen, const Vector &offset) { - int margin(attackTypeMenu.Height() / 48); + int margin(attackTypeMenu.Height() * 3 / 48); int tagHeight(attackTypeMenu.Height() - 2 * margin); int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2 - 2 * margin); int xOffset((BackgroundWidth() - 2 * tagWidth - 2 * margin) / 2); Point tagPosition[4]; - tagPosition[0] = Point(xOffset, BackgroundHeight() - 2 * tagHeight - margin); - tagPosition[1] = Point(xOffset + tagWidth + 2 * margin, BackgroundHeight() - 2 * tagHeight - margin); + tagPosition[0] = Point(xOffset, BackgroundHeight() - 2 * tagHeight - 3 * margin); + tagPosition[1] = Point(xOffset + tagWidth + 2 * margin, BackgroundHeight() - 2 * tagHeight - 3 * margin); tagPosition[2] = Point(xOffset, BackgroundHeight() - tagHeight - margin); tagPosition[3] = Point(xOffset + tagWidth + 2 * margin, BackgroundHeight() - tagHeight - margin); diff --git a/src/battle/HeroTag.cpp b/src/battle/HeroTag.cpp index 0b7aa27..87f35dd 100644 --- a/src/battle/HeroTag.cpp +++ b/src/battle/HeroTag.cpp @@ -25,9 +25,11 @@ void HeroTag::Render(SDL_Surface *screen, int width, int height, Point posi frame->Draw(screen, position, width, height); } + int verticalHeroOffset((height - hero->Sprite()->Height()) / 2); + Vector heroOffset( - (align == LEFT) ? 3 : width - hero->Sprite()->Width() - 3, - height - hero->Sprite()->Height() - 3); + (align == LEFT) ? verticalHeroOffset : width - hero->Sprite()->Width() - verticalHeroOffset, + verticalHeroOffset); hero->Sprite()->Draw(screen, position + heroOffset, 0, hero->Health() > 0 ? 0 : 2); } diff --git a/src/main.cpp b/src/main.cpp index 767464b..f12b275 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,7 +69,7 @@ int main(int argc, char **argv) { monster.SetSprite(&dummySprite); SDL_Surface *heroImg(IMG_Load("test-data/hero.png")); - Sprite heroSprite(heroImg, 96, 96); + Sprite heroSprite(heroImg, 64, 64); Hero hero; hero.SetName("Name"); hero.SetLevel(34); diff --git a/test-data/battle-bg.png b/test-data/battle-bg.png index 4c8a0af..b62ab74 100644 Binary files a/test-data/battle-bg.png and b/test-data/battle-bg.png differ diff --git a/test-data/hero.png b/test-data/hero.png index c61b217..ce5df5c 100644 Binary files a/test-data/hero.png and b/test-data/hero.png differ