Deux Ex Machina

This commit is contained in:
Bram Verhulst
2024-06-09 23:23:55 +02:00
parent 5f1dcd5788
commit caabb12838
17 changed files with 151 additions and 77 deletions

View File

@@ -1,6 +1,8 @@
#include "pch.h"
#include "GameManager.h"
#include "Gui/Screens/ScreenManager.h"
GameManager* GameManager::m_pInstance = nullptr;
@@ -36,6 +38,9 @@ void GameManager::DecreaseFuel(float fuel) {
}
void GameManager::AddFuel(float fuel) {
m_Fuel += fuel;
if(m_Fuel > this->GetMaxFuel()) {
m_Fuel = this->GetMaxFuel();
}
}
void GameManager::SetHullIntegrity(int hullIntegrity) {
m_HullIntegrity = hullIntegrity;
@@ -72,11 +77,14 @@ void GameManager::Update(float elapsedSecs) {
if (m_HullIntegrity <= 0 or m_Fuel <= 0) {
m_pPlayer->Die();
m_GameOver = true;
ScreenManager::GetInstance()->OpenScreen(ScreenManager::m_GameOverScreen);
}
if(m_Fuel <= 20) {
if(m_FuelLowSound->IsPlaying() == false) {
m_FuelLowSound->Play(1);
if(!m_GameOver) {
if(m_Fuel <= 20) {
if(m_FuelLowSound->IsPlaying() == false) {
m_FuelLowSound->Play(1);
}
}
}
}