]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/HeroTag.cpp
added Frame class for drawing bordered windows
[l2e.git] / src / battle / HeroTag.cpp
index 2461e4de92363b2a19b0c020e1dd5eb1ec6c64c1..0b7aa2700b83f33308bc05644100b0f101c5323c 100644 (file)
@@ -7,28 +7,28 @@
 
 #include "HeroTag.h"
 
+#include "Hero.h"
+#include "../geometry/operators.h"
+#include "../geometry/Vector.h"
+#include "../graphics/Frame.h"
+#include "../graphics/Sprite.h"
+
 using geometry::Point;
+using geometry::Vector;
 
 namespace battle {
 
-void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> position) const {
-       SDL_Rect destRect;
-       destRect.x = position.X();
-       destRect.y = position.Y();
-       destRect.w = width;
-       destRect.h = height;
-
-       destRect.x += 1;
-       destRect.y += 1;
-       destRect.w -= 2;
-       destRect.h -= 2;
-       SDL_FillRect(screen, &destRect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
+void HeroTag::Render(SDL_Surface *screen, int width, int height, Point<int> position, bool active) const {
+       if (active) {
+               activeFrame->Draw(screen, position, width, height);
+       } else {
+               frame->Draw(screen, position, width, height);
+       }
 
-       destRect.x += 1;
-       destRect.y += 1;
-       destRect.w -= 2;
-       destRect.h -= 2;
-       SDL_FillRect(screen, &destRect, SDL_MapRGB(screen->format, 0, 0, 0));
+       Vector<int> heroOffset(
+                       (align == LEFT) ? 3 : width - hero->Sprite()->Width() - 3,
+                       height - hero->Sprite()->Height() - 3);
+       hero->Sprite()->Draw(screen, position + heroOffset, 0, hero->Health() > 0 ? 0 : 2);
 }
 
 }