mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 22:41:48 +01:00
Started on GuiIcon, General fixes
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "GuiMeter.h"
|
||||
|
||||
#include "TextureManager.h"
|
||||
#include "utils.h"
|
||||
GuiMeter::GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, int frameCount, TextureManager* manager): m_Position(pos), m_FrameCount(frameCount) {
|
||||
m_Animation = new Animation(manager->GetTexture(filePath),frameCount, 0.0f, Rectf{0, 0, frameSize.x, frameSize.y}, false);
|
||||
|
||||
@@ -13,6 +14,6 @@ void GuiMeter::Draw() const {
|
||||
m_Animation->Draw(m_Position);
|
||||
}
|
||||
void GuiMeter::Update(float elapsedSec) {
|
||||
|
||||
|
||||
const int frame = static_cast<int>(utils::map(m_Value, 0.0f, m_MaxValue, 0, (float)m_Animation->GetFrameCount()));
|
||||
m_Animation->SetFrame(frame);
|
||||
}
|
||||
@@ -15,11 +15,17 @@ public:
|
||||
virtual void Draw() const override;
|
||||
virtual void Update(float elapsedSec) override;
|
||||
|
||||
void SetValue(float value) {
|
||||
m_Value = value;
|
||||
}
|
||||
|
||||
private:
|
||||
Animation* m_Animation{ nullptr };
|
||||
Vector2f m_Position;
|
||||
|
||||
float m_Value{ 0.0f };
|
||||
|
||||
const float m_MaxValue{ 100.0f };
|
||||
|
||||
int m_FrameCount;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user