mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 21:01:48 +01:00
Add Main UI, Fuel meter. Add particles to player digging
This commit is contained in:
@@ -3,17 +3,25 @@
|
||||
|
||||
#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);
|
||||
|
||||
GuiMeter::GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, int frameCount, TextureManager* manager): GuiMeter(
|
||||
filePath, pos, frameSize, frameSize, frameCount, manager) {
|
||||
}
|
||||
GuiMeter::GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, Vector2f drawSize, int frameCount, TextureManager* manager): m_Position(pos),
|
||||
m_DrawSize(drawSize), m_FrameCount(frameCount) {
|
||||
m_Animation = new Animation(manager->GetTexture(filePath), frameCount, 0.0f, Rectf { 0, 0, frameSize.x, frameSize.y }, false);
|
||||
}
|
||||
GuiMeter::~GuiMeter() {
|
||||
delete m_Animation;
|
||||
}
|
||||
void GuiMeter::Draw() const {
|
||||
m_Animation->Draw(m_Position);
|
||||
m_Animation->Draw(m_Position, Rectf{m_Position, m_DrawSize});
|
||||
utils::DrawRect(Rectf { m_Position, m_DrawSize});
|
||||
}
|
||||
void GuiMeter::Update(float elapsedSec) {
|
||||
m_Value += 1;
|
||||
const int frame = static_cast<int>(utils::map(m_Value, 0.0f, m_MaxValue, 0, (float)m_Animation->GetFrameCount()));
|
||||
m_Animation->SetFrame(frame);
|
||||
}
|
||||
}
|
||||
void GuiMeter::SetValue(float value) {
|
||||
m_Value = value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user