Files
dae16-VerhulstBram-GameProject/Game/Gui/Screens/MainScreen.cpp
2024-05-16 12:44:53 +02:00

46 lines
1.6 KiB
C++

#include "pch.h"
#include "MainScreen.h"
#include "colors.h"
#include "utils.h"
#include "Gui/GuiText.h"
MainScreen::MainScreen(TextureManager* manager) : Screen("", Vector2f{0, 0}, Vector2f{900.f, 500.f}, manager) {
Vector2f ScreenSize = utils::GetViewport();
Vector2f FuelFrameSize{ 336, 77 };
Vector2f HullFrameSize{ 61, 76 };
m_FuelMeter = new GuiMeter("gui/main/fuel/fuel.png", Vector2f{HullFrameSize.x + 10, ScreenSize.y - FuelFrameSize.y }, FuelFrameSize,FuelFrameSize / 1.3, 21, manager);
this->AddElement(m_FuelMeter);
m_HullMeter = new GuiMeter("gui/main/hull/hull.png", Vector2f{5, ScreenSize.y - HullFrameSize.y - 10 }, HullFrameSize, HullFrameSize, 50, manager);
this->AddElement(m_HullMeter);
Vector2f DepthMeterPosition{10, ScreenSize.y - 120};
m_DepthText = new GuiText(DepthMeterPosition, "Depth: 20", "fonts/Arial.ttf", 20, Colors::YELLOW);
this->AddElement(m_DepthText);
Vector2f ScoreMeterPosition{10, ScreenSize.y - 150};
m_ScoreText = new GuiText(ScoreMeterPosition, "Score: 0", "fonts/Arial.ttf", 20, Colors::YELLOW);
this->AddElement(m_ScoreText);
}
MainScreen::~MainScreen() = default;
void MainScreen::Draw() const {
Screen::Draw();
}
void MainScreen::Update(float elapsedSecs) {
Screen::Update(elapsedSecs);
}
void MainScreen::SetFuelMeterValue(float value) const {
m_FuelMeter->SetValue(value);
}
void MainScreen::SetHullMeterValue(float value) const {
m_HullMeter->SetValue(value);
}
void MainScreen::SetDepth(const std::string& text) const {
m_DepthText->ChangeText(text);
}
void MainScreen::SetScore(const std::string& text) const {
m_ScoreText->ChangeText(text);
}