This commit is contained in:
Bram Verhulst
2024-06-04 14:38:46 +02:00
parent e1165fdcb4
commit d7389411f5
9 changed files with 68 additions and 37 deletions

View File

@@ -2,9 +2,10 @@
#include "Screen.h"
Screen::Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) {
if(!filePath.empty()) {
if (!filePath.empty()) {
m_Background = manager->GetTexture(filePath);
} else {
}
else {
m_Background = nullptr;
}
}
@@ -13,13 +14,16 @@ Screen::~Screen() {
delete b;
}
}
void Screen::AddElement(GuiElement* element) {
m_Elements.push_back(element);
}
void Screen::Update(float elapsedSecs) {
for (GuiElement* b : m_Elements) {
b->Update(elapsedSecs);
}
}
void Screen::Draw() const {
if(m_Background != nullptr) { //Incase there is no background
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);