Add Main UI, Fuel meter. Add particles to player digging

This commit is contained in:
Bram Verhulst
2024-05-14 12:28:37 +02:00
parent d5c002c2b2
commit 600050c198
39 changed files with 251 additions and 108 deletions

View File

@@ -2,7 +2,11 @@
#include "Screen.h"
Screen::Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
m_Background = manager->GetTexture(filePath);
if(!filePath.empty()) {
m_Background = manager->GetTexture(filePath);
} else {
m_Background = nullptr;
}
}
Screen::~Screen() {
for (GuiElement* b : m_Elements) {
@@ -15,11 +19,13 @@ void Screen::Update(float elapsedSecs) {
}
}
void Screen::Draw() const {
Rectf dest = Rectf(m_Position, m_Size);
Rectf src = Rectf(0, 0, m_Background->GetWidth(), m_Background->GetHeight());
m_Background->Draw(dest, src, false);
if(m_Background != nullptr) { //Incase there is no background
Rectf dest = Rectf(m_Position, m_Size);
Rectf src = Rectf(0, 0, m_Background->GetWidth(), m_Background->GetHeight());
m_Background->Draw(dest, src, false);
}
for (GuiElement* b : m_Elements) {
b->Draw();
for (GuiElement* GuiElement : m_Elements) {
GuiElement->Draw();
}
}