diff --git a/.idea/.idea.Motherload/.idea/workspace.xml b/.idea/.idea.Motherload/.idea/workspace.xml
index 64d3b02..2733820 100644
--- a/.idea/.idea.Motherload/.idea/workspace.xml
+++ b/.idea/.idea.Motherload/.idea/workspace.xml
@@ -10,54 +10,23 @@
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
@@ -387,6 +356,10 @@
+
+
+
+
@@ -398,6 +371,7 @@
+
@@ -625,7 +599,7 @@
-
+
@@ -795,7 +769,15 @@
1717504732974
-
+
+
+ 1717963413007
+
+
+
+ 1717963413007
+
+
@@ -825,7 +807,8 @@
-
+
+
diff --git a/Game/Game.h b/Game/Game.h
index bc7f3c1..b60dbbe 100644
--- a/Game/Game.h
+++ b/Game/Game.h
@@ -47,6 +47,6 @@ private:
bool m_IsRightMouseDown {};
- bool m_ImGui{ true };
+ bool m_ImGui{ false };
};
diff --git a/Game/Game.vcxproj b/Game/Game.vcxproj
index 000c662..8f022f3 100644
--- a/Game/Game.vcxproj
+++ b/Game/Game.vcxproj
@@ -533,6 +533,7 @@
true
true
+
@@ -784,6 +785,7 @@
+
diff --git a/Game/GameManager.cpp b/Game/GameManager.cpp
index 0071042..0ec34d7 100644
--- a/Game/GameManager.cpp
+++ b/Game/GameManager.cpp
@@ -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);
+ }
}
}
}
diff --git a/Game/GameManager.h b/Game/GameManager.h
index 78f984a..105866a 100644
--- a/Game/GameManager.h
+++ b/Game/GameManager.h
@@ -49,6 +49,7 @@ private:
Player* m_pPlayer{ nullptr };
SoundEffect* m_FuelLowSound{ nullptr };
+ bool m_GameOver{ false };
};
diff --git a/Game/Gui/Screens/GameOver/GameOverScreen.cpp b/Game/Gui/Screens/GameOver/GameOverScreen.cpp
new file mode 100644
index 0000000..586acf1
--- /dev/null
+++ b/Game/Gui/Screens/GameOver/GameOverScreen.cpp
@@ -0,0 +1,31 @@
+#include "pch.h"
+#include "GameOverScreen.h"
+
+#include "colors.h"
+#include "utils.h"
+GameOverScreen::GameOverScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): Screen(filePath, pos, size, manager){
+ m_SkullTexture = manager->GetTexture("gui/gameover/skull.png");
+
+ GuiText* text = new GuiText(Vector2f{360, 150}, "Press Space To Quit", "fonts/Arial.ttf", 20, Colors::YELLOW);
+ AddElement(text);
+}
+GameOverScreen::~GameOverScreen() {
+}
+void GameOverScreen::Draw() const {
+ Screen::Draw();
+ //1230 x 1087
+ m_SkullTexture->Draw(Rectf{ 350, 200, 1230 / 5, 1087 / 5 });
+
+}
+void GameOverScreen::Update(float elapsedSecs) {
+ Screen::Update(elapsedSecs);
+ if(utils::isKeyDown(SDL_SCANCODE_SPACE)){
+ SDL_Event quitEvent;
+ quitEvent.type = SDL_QUIT;
+ SDL_PushEvent(&quitEvent);
+ }
+}
+void GameOverScreen::MarkDirty() {
+}
+void GameOverScreen::SellAll() {
+}
diff --git a/Game/Gui/Screens/GameOver/GameOverScreen.h b/Game/Gui/Screens/GameOver/GameOverScreen.h
new file mode 100644
index 0000000..9e8695e
--- /dev/null
+++ b/Game/Gui/Screens/GameOver/GameOverScreen.h
@@ -0,0 +1,19 @@
+#pragma once
+#include "../../Screen.h"
+#include "Gui/GuiText.h"
+
+class GameOverScreen final : public Screen {
+public:
+ GameOverScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
+ virtual ~GameOverScreen() override;
+
+ virtual void Draw() const override;
+ virtual void Update(float elapsedSecs) override;
+
+ void MarkDirty();
+ void SellAll();
+
+private:
+ Texture* m_SkullTexture{ nullptr };
+
+};
diff --git a/Game/Gui/Screens/ScreenManager.cpp b/Game/Gui/Screens/ScreenManager.cpp
index 9b186c1..83d1c08 100644
--- a/Game/Gui/Screens/ScreenManager.cpp
+++ b/Game/Gui/Screens/ScreenManager.cpp
@@ -4,10 +4,12 @@
#include "FuelScreen/FuelScreen.h"
#include "SellScreen/SellScreen.h"
#include "utils.h"
+#include "GameOver/GameOverScreen.h"
ScreenManager* ScreenManager::m_pInstance = nullptr;
Screen* ScreenManager::m_FuelScreen { nullptr };
Screen* ScreenManager::m_SellScreen { nullptr };
+Screen* ScreenManager::m_GameOverScreen { nullptr };
ScreenManager * ScreenManager::GetInstance() {
@@ -44,6 +46,7 @@ bool ScreenManager::IsScreenOpen() const {
ScreenManager::~ScreenManager() {
delete m_FuelScreen;
delete m_SellScreen;
+ delete m_GameOverScreen;
}
void ScreenManager::InitializeScreens() {
Vector2f fuelScreenSize = Vector2f { 492, 396 };
@@ -54,5 +57,9 @@ void ScreenManager::InitializeScreens() {
Vector2f sellScreenCenter = Vector2f { utils::GetViewport().x / 2 - sellScreenSize.x / 2, utils::GetViewport().y / 2 - sellScreenSize.y / 2 };
m_SellScreen = new SellScreen { "gui/sell/background.png", sellScreenCenter, sellScreenSize, TextureManager::GetInstance() };
+ Vector2f gameOverScreenSize = Vector2f { 533, 398 };
+ Vector2f gameOverScreenCenter = Vector2f { utils::GetViewport().x / 2 - gameOverScreenSize.x / 2, utils::GetViewport().y / 2 - gameOverScreenSize.y / 2 };
+ m_GameOverScreen = new GameOverScreen { "", gameOverScreenCenter, gameOverScreenSize, TextureManager::GetInstance() };
+
//m_Button = Button { "gui/close.png", closeButtonPos, closeButtonSize, TextureManager::GetInstance() };
}
diff --git a/Game/Gui/Screens/ScreenManager.h b/Game/Gui/Screens/ScreenManager.h
index 6361989..0b6c358 100644
--- a/Game/Gui/Screens/ScreenManager.h
+++ b/Game/Gui/Screens/ScreenManager.h
@@ -21,6 +21,7 @@ public:
static Screen* m_FuelScreen;
static Screen* m_SellScreen;
+ static Screen* m_GameOverScreen;
private:
ScreenManager() = default;
diff --git a/Game/Gui/Screens/SellScreen/SellScreen.cpp b/Game/Gui/Screens/SellScreen/SellScreen.cpp
index c06699a..6a7d9e5 100644
--- a/Game/Gui/Screens/SellScreen/SellScreen.cpp
+++ b/Game/Gui/Screens/SellScreen/SellScreen.cpp
@@ -12,6 +12,7 @@ SellScreen::SellScreen(const std::string& filePath, Vector2f pos, Vector2f size,
const Vector2f ScreenCenter = Vector2f { utils::GetViewport().x / 2, utils::GetViewport().y / 2 };
const Vector2f sellScreenCenter = ScreenCenter - sellScreenSize / 2;
+ m_BuySound = new SoundEffect { "sound/buy.wav" };
const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 };
Vector2f closeButtonPos = sellScreenCenter + closeButtonOffset;
@@ -36,6 +37,7 @@ SellScreen::SellScreen(const std::string& filePath, Vector2f pos, Vector2f size,
sellAllButton->SetOnClick([this]()
{
this->SellAll();
+ m_BuySound->Play(0);
});
this->AddElement(sellAllButton);
@@ -48,6 +50,7 @@ SellScreen::~SellScreen() {
for (SellSreenRow* row : m_Rows) {
delete row;
}
+ delete m_BuySound;
}
void SellScreen::Draw() const {
Screen::Draw();
diff --git a/Game/Gui/Screens/SellScreen/SellScreen.h b/Game/Gui/Screens/SellScreen/SellScreen.h
index 22f5d2c..41c99da 100644
--- a/Game/Gui/Screens/SellScreen/SellScreen.h
+++ b/Game/Gui/Screens/SellScreen/SellScreen.h
@@ -3,6 +3,8 @@
#include "../../Screen.h"
#include "Gui/GuiText.h"
+class SoundEffect;
+
class SellScreen final : public Screen {
public:
SellScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager);
@@ -20,4 +22,7 @@ private:
std::vector m_Rows;
bool m_AreRowsDirty { true };
+
+ SoundEffect* m_BuySound { nullptr };
+
};
diff --git a/Game/Gui/Screens/SellScreen/SellSreenRow.cpp b/Game/Gui/Screens/SellScreen/SellSreenRow.cpp
index ca5fe8e..1eb4028 100644
--- a/Game/Gui/Screens/SellScreen/SellSreenRow.cpp
+++ b/Game/Gui/Screens/SellScreen/SellSreenRow.cpp
@@ -26,8 +26,8 @@ void SellSreenRow::Draw() const {
Vector2f amountPos { namePos.x + 100, m_Pos.y + 8 };
m_CalculationText->Draw(amountPos);
- utils::SetColor(Colors::GREEN);
- utils::DrawRect(Rectf { m_Pos, m_Size });
+ // utils::SetColor(Colors::GREEN);
+ // utils::DrawRect(Rectf { m_Pos, m_Size });
}
void SellSreenRow::Update(float elapsedSecs) {
// m_NameText->ChangeText("EXAMPLE");
diff --git a/Game/Levels/World/Building.cpp b/Game/Levels/World/Building.cpp
index 73f770f..98a2df5 100644
--- a/Game/Levels/World/Building.cpp
+++ b/Game/Levels/World/Building.cpp
@@ -16,11 +16,11 @@ Building::Building(const std::string& filePath, const Vector2f& position, const
void Building::Draw() const {
utils::SetColor(Colors::WHITE);
m_Texture->Draw(m_Position);
- utils::SetColor(Colors::GREEN);
- Rectf temp = m_BoundingBox;
- temp.left += m_Position.x;
- temp.bottom += m_Position.y;
- utils::DrawRect(temp);
+ // utils::SetColor(Colors::GREEN);
+ // Rectf temp = m_BoundingBox;
+ // temp.left += m_Position.x;
+ // temp.bottom += m_Position.y;
+ // utils::DrawRect(temp);
}
void Building::Update(float dt, const Rectf& objectBoundingBox) {
if (IsObjectInHitbox(objectBoundingBox)) {
diff --git a/Game/Levels/World/WorldLevel.cpp b/Game/Levels/World/WorldLevel.cpp
index a498cf5..45ce002 100644
--- a/Game/Levels/World/WorldLevel.cpp
+++ b/Game/Levels/World/WorldLevel.cpp
@@ -36,6 +36,13 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
m_GridManager.GetTileAtIndex(x, 0)->SetTileType(GroundTileTypeManager::GetInstance()->AIR);
m_GridManager.GetTileAtIndex(x, 1)->SetTileType(GroundTileTypeManager::GetInstance()->GRASS);
}
+
+ //Add to walls to the side of stone
+ for (int y { 0 }; y < WORLD_HEIGHT - 1; ++y) {
+ m_GridManager.GetTileAtIndex(0, y)->SetTileType(GroundTileTypeManager::GetInstance()->STONE);
+ m_GridManager.GetTileAtIndex(WORLD_WIDTH - 1, y)->SetTileType(GroundTileTypeManager::GetInstance()->STONE);
+ }
+
Building* fuelBuilding = new Building { "buildings/fuelStation.png", Vector2f { -700, -52 }, Rectf{0 ,0, 50, 50}, TextureManager::GetInstance() };
fuelBuilding->SetOnEnterHitbox([]() {
ScreenManager::GetInstance()->OpenScreen(ScreenManager::m_FuelScreen);
@@ -78,8 +85,8 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
m_MainScreen = new MainScreen(TextureManager::GetInstance());
GameManager::GetInstance().SetMainScreen(m_MainScreen);
- m_Sun = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.5f, TextureManager::GetInstance()->GetTexture("sun.png"));
- m_Moon = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.5f, TextureManager::GetInstance()->GetTexture("moon.png"), M_PI);
+ m_Sun = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.1f, TextureManager::GetInstance()->GetTexture("sun.png"));
+ m_Moon = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.1f, TextureManager::GetInstance()->GetTexture("moon.png"), M_PI);
GameManager::GetInstance().SetFuel(100);
GameManager::GetInstance().SetHullIntegrity(100);
@@ -87,7 +94,10 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
GameManager::GetInstance().SetPlayer(&m_Player);
m_BackgroundMusic = new SoundStream("sound/bgm.wav");
- m_BackgroundMusic->Play(0);
+ m_BackgroundMusic->Play(-1);
+
+ GameManager::GetInstance().SetMoney(100);
+
}
WorldLevel::~WorldLevel() {
delete m_MainScreen;
@@ -149,6 +159,7 @@ void WorldLevel::Update(float elapsedSec) {
}
//Move the camera when the player gets to the edge
+ //Also lock the camera from going below -800 and above -100
if(m_FollowPlayer) {
Vector2f playerPos = m_Player.GetPosition();
Vector2f newCameraPos = m_pCamera->GetPosition();
@@ -158,12 +169,13 @@ void WorldLevel::Update(float elapsedSec) {
if (playerPos.x > newCameraPos.x + m_Viewport.width - 100) {
newCameraPos.x = playerPos.x - m_Viewport.width + 100;
}
- if (playerPos.y < newCameraPos.y + 50) {
- newCameraPos.y = playerPos.y - 50;
+ if (playerPos.y < newCameraPos.y + 100) {
+ newCameraPos.y = playerPos.y - 100;
}
- if (playerPos.y > newCameraPos.y + m_Viewport.height - 100) {
- newCameraPos.y = playerPos.y - m_Viewport.height + 100;
+ if (playerPos.y > newCameraPos.y + m_Viewport.height - 150) {
+ newCameraPos.y = playerPos.y - m_Viewport.height + 150;
}
+ newCameraPos.x = utils::clamp(newCameraPos.x, -800, -100);
m_pCamera->SetPosition(newCameraPos);
}
@@ -199,11 +211,11 @@ void WorldLevel::Draw() const {
m_TopCover->Draw(Rectf{-850, -70, 850, -70 + 32}, Rectf{0, 0, WORLD_WIDTH * 50, 32});
for (Collision::CollisionRect rect : m_Rects) {
- utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
+ // utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
}
- utils::SetColor(Colors::WHITE);
- utils::FillEllipse(m_MousePos, 2, 2);
+ // utils::SetColor(Colors::WHITE);
+ // utils::FillEllipse(m_MousePos, 2, 2);
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
@@ -211,12 +223,12 @@ void WorldLevel::Draw() const {
}
}
- utils::SetColor(Colors::MAGENTA);
- utils::FillEllipse(-5, -5, 5, 5);
+ // utils::SetColor(Colors::MAGENTA);
+ // utils::FillEllipse(-5, -5, 5, 5);
- if (m_pSelectedTile != nullptr) {
- m_pSelectedTile->Draw();
- }
+ // if (m_pSelectedTile != nullptr) {
+ // m_pSelectedTile->Draw();
+ // }
for(Building* building : m_Buildings) {
building->Draw();
@@ -224,14 +236,14 @@ void WorldLevel::Draw() const {
m_Player.Draw();
- utils::SetColor(Colors::GREEN);
- utils::DrawArrow(Vector2f{0, 0}, m_MousePos);
+ // utils::SetColor(Colors::GREEN);
+ // utils::DrawArrow(Vector2f{0, 0}, m_MousePos);
m_pCamera->EndRendering();
- utils::FillRect(utils::GetMousePos(), 10, 10);
+ // utils::FillRect(utils::GetMousePos(), 10, 10);
- utils::DrawRect(50, 50, m_Viewport.width - 100, m_Viewport.height - 100);
+ // utils::DrawRect(50, 50, m_Viewport.width - 100, m_Viewport.height - 100);
const Screen* screen = m_ScreenManager->GetCurrentScreen();
if (screen != nullptr) {
diff --git a/Game/Player.cpp b/Game/Player.cpp
index e22df9d..343c1f7 100644
--- a/Game/Player.cpp
+++ b/Game/Player.cpp
@@ -84,6 +84,10 @@ Player::~Player() {
for (Particle* particle : m_DigParticles) {
delete particle;
}
+
+ for (Particle* particle : m_SmokeParticles) {
+ delete particle;
+ }
}
Collision::CollisionRect Player::GetCollisionRect() const {
@@ -112,12 +116,10 @@ void Player::Draw() const {
{
utils::SetColor(Colors::WHITE);
m_CurrentAnimation->Draw(Vector2f { 0, 0 }, Rectf { 0, 0, frameWidth, frameWidth });
- utils::SetColor(Colors::GREEN);
}
glPopMatrix();
- utils::FillEllipse(m_OutletPos + m_Position, 5, 5);
for (Particle* particle : m_DigParticles) {
utils::SetColor(Colors::WHITE);
particle->Draw();
@@ -271,8 +273,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
m_SmokeTimer += elapsedTime;
if (m_SmokeTimer >= m_SmokeTime) {
m_SmokeTimer = 0.0f;
- Vector2f Dir { static_cast(m_Direction == PlayerDirection::Left ? 30 : -30), 20 };
- Particle* NewSmokeParticle = new Particle(m_OutletPos + m_Position, Dir, Vector2f { 0.0f, 9.81f * 30}, 5.f, TextureManager::GetInstance()->GetTexture("particles/smoke.png"));
+ Vector2f Dir { static_cast(m_Direction == PlayerDirection::Left ? 60 : -60), 20 };
+ Particle* NewSmokeParticle = new Particle(m_OutletPos + m_Position, Dir, Vector2f { 0.0f, 9.81f * 5}, 1.f, TextureManager::GetInstance()->GetTexture("particles/smoke.png"));
NewSmokeParticle->SetFlipped(m_Direction == PlayerDirection::Left);
m_SmokeParticles.push_back(NewSmokeParticle);
}
diff --git a/Game/Player.h b/Game/Player.h
index 93a5210..8dcc8cb 100644
--- a/Game/Player.h
+++ b/Game/Player.h
@@ -83,7 +83,7 @@ private:
Vector2f m_OutletPos;
Vector2f m_OutLeftPos{ 55, 45};
- Vector2f m_OutRightPos{ 0, 45 };
+ Vector2f m_OutRightPos{ -40, 45 };
Vector2f m_Vel;
@@ -154,5 +154,5 @@ private:
bool m_DidSoundChange{ false };
//Testing
- bool m_DrawCollisionRect { true };
+ bool m_DrawCollisionRect { false };
};
diff --git a/Resources/gui/gameover/skull.png b/Resources/gui/gameover/skull.png
new file mode 100644
index 0000000..67aaa99
Binary files /dev/null and b/Resources/gui/gameover/skull.png differ