]> git.localhorst.tv Git - l2e.git/blob - src/battle/HeroTag.cpp
87f35dd171813f4db3e093c77b5d99f3ed0ab8e7
[l2e.git] / src / battle / HeroTag.cpp
1 /*
2  * HeroTag.cpp
3  *
4  *  Created on: Aug 6, 2012
5  *      Author: holy
6  */
7
8 #include "HeroTag.h"
9
10 #include "Hero.h"
11 #include "../geometry/operators.h"
12 #include "../geometry/Vector.h"
13 #include "../graphics/Frame.h"
14 #include "../graphics/Sprite.h"
15
16 using geometry::Point;
17 using geometry::Vector;
18
19 namespace battle {
20
21 void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> position, bool active) const {
22         if (active) {
23                 activeFrame->Draw(screen, position, width, height);
24         } else {
25                 frame->Draw(screen, position, width, height);
26         }
27
28         int verticalHeroOffset((height - hero->Sprite()->Height()) / 2);
29
30         Vector<int> heroOffset(
31                         (align == LEFT) ? verticalHeroOffset : width - hero->Sprite()->Width() - verticalHeroOffset,
32                         verticalHeroOffset);
33         hero->Sprite()->Draw(screen, position + heroOffset, 0, hero->Health() > 0 ? 0 : 2);
34 }
35
36 }