commit a1402040340514d7cd0baf9a55ad0e14ad64fa67
parent 734b859582b27a2867d67a83fc272eb64ee35993
Author: Charles Baptista <charles@charlesbaptista.com>
Date: Thu, 28 May 2020 21:08:37 -0400
Fixed widget draw postion bug
Diffstat:
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/TapestryEngine/HUD.cpp b/TapestryEngine/HUD.cpp
@@ -1,9 +1,11 @@
#include "HUD.h"
-void CalcElementScreenPosition(Widget* wid, SDL_Rect elementRect)
+struct SDL_Rect CalcElementScreenPosition(Widget* wid, SDL_Rect *elementRect)
{
- elementRect.x += wid->GetPos()->x;
- elementRect.y += wid->GetPos()->y;
+ struct SDL_Rect drawRect = *elementRect;
+ drawRect.x += (wid->GetPos()->x);
+ drawRect.y += (wid->GetPos()->y);
+ return drawRect;
};
bool HUD::LogWidget(Widget* wid)
@@ -56,8 +58,10 @@ bool LifeMeter::WidgetUpdate()
bool LifeMeter::WidgetDraw()
{
SDL_RenderCopy(mren, mBase.img, NULL, &mBase.pos);
- CalcElementScreenPosition(this, mLifebar.pos);
- SDL_RenderCopy(mren, mLifebar.img, NULL, &mLifebar.pos);
+ CalcElementScreenPosition(this, &mLifebar.pos);
+ struct SDL_Rect drawRect = CalcElementScreenPosition(this, &mLifebar.pos);
+ SDL_RenderCopy(mren, mLifebar.img, NULL, &drawRect);
+
return true;
}
//
diff --git a/TapestryEngine/HUD.h b/TapestryEngine/HUD.h
@@ -41,7 +41,7 @@ protected:
};
-void CalcElementScreenPosition(Widget* wid, SDL_Rect elementRect);
+struct SDL_Rect CalcElementScreenPosition(Widget* wid, SDL_Rect elementRect);
class LifeMeter : public Widget
{