Add fly animations

This commit is contained in:
Bram Verhulst
2024-05-29 00:00:29 +02:00
parent 3c83e566dd
commit e1165fdcb4
31 changed files with 580 additions and 157 deletions

View File

@@ -1,6 +1,8 @@
#include "pch.h"
#include "FuelScreen.h"
#include "colors.h"
#include "GameManager.h"
#include "ScreenManager.h"
#include "utils.h"
FuelScreen::FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): Screen(filePath, pos, size, manager)
@@ -38,14 +40,33 @@ FuelScreen::FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size,
const Vector2f fillTankButtonPos = Vector2f { 450, 108 };
GuiButton* fillTankButton = new GuiButton { "gui/fuel/fillTank.png", fillTankButtonPos, Vector2f{0,0}, TextureManager::GetInstance() };
this->AddElement(fillTankButton);
Vector2f offset{ 50, 320};
m_MoneyText = new GuiText {fuelScreenCenter + offset, "$ 20", "fonts/Arial.ttf", 20, Colors::YELLOW };
}
FuelScreen::~FuelScreen() = default;
FuelScreen::~FuelScreen() {
delete m_MoneyText;
};
void FuelScreen::Draw() const {
int currentFuel = GameManager::GetInstance().GetFuel();
int maxFuel = GameManager::GetInstance().GetMaxFuel();
utils::SetColor(Colors::ORANGE);
Vector2f fuelBarPos = Vector2f { 275, 135 };
const int MAX_HEIGHT = 210;
Vector2f fuelBarSize = Vector2f { 40, utils::map(currentFuel, 0, maxFuel, 0, MAX_HEIGHT) };
utils::FillRect(Rectf{fuelBarPos, fuelBarSize});
Screen::Draw();
m_MoneyText->Draw();
}
void FuelScreen::Update(float elapsedSecs) {
Screen::Update(elapsedSecs);
m_MoneyText->ChangeText("$ " + std::to_string(GameManager::GetInstance().GetMoney()));
}