diff --git a/.idea/.idea.Motherload/.idea/workspace.xml b/.idea/.idea.Motherload/.idea/workspace.xml index fbc1ca4..64d3b02 100644 --- a/.idea/.idea.Motherload/.idea/workspace.xml +++ b/.idea/.idea.Motherload/.idea/workspace.xml @@ -11,14 +11,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - { - "keyToString": { - "C++ Project.Game.executor": "Debug", - "RunOnceActivity.OpenProjectViewOnStart": "true", - "RunOnceActivity.ShowReadmeOnStart": "true", - "ignore.virus.scanning.warn.message": "true", - "node.js.detected.package.eslint": "true", - "node.js.detected.package.tslint": "true", - "node.js.selected.package.eslint": "(autodetect)", - "node.js.selected.package.tslint": "(autodetect)", - "nodejs_package_manager_path": "npm", - "settings.editor.selected.configurable": "preferences.pluginManager", - "vue.rearranger.settings.migration": "true" + +}]]> @@ -449,6 +624,8 @@ + + - @@ -639,14 +824,8 @@ - - - - - - - + + diff --git a/Assets/Player/PlayerDie.aseprite b/Assets/Player/PlayerDie.aseprite new file mode 100644 index 0000000..d4b9f75 Binary files /dev/null and b/Assets/Player/PlayerDie.aseprite differ diff --git a/Assets/Player/PlayerDieLoop.aseprite b/Assets/Player/PlayerDieLoop.aseprite new file mode 100644 index 0000000..84636d9 Binary files /dev/null and b/Assets/Player/PlayerDieLoop.aseprite differ diff --git a/Assets/PlayerWalk.png b/Assets/PlayerWalk.png deleted file mode 100644 index ff6cce1..0000000 Binary files a/Assets/PlayerWalk.png and /dev/null differ diff --git a/Assets/screenshot.jpg b/Assets/screenshot.jpg new file mode 100644 index 0000000..ddc6b79 Binary files /dev/null and b/Assets/screenshot.jpg differ diff --git a/Engine/SoundEffect.cpp b/Engine/SoundEffect.cpp index 4f97c57..db31324 100644 --- a/Engine/SoundEffect.cpp +++ b/Engine/SoundEffect.cpp @@ -58,3 +58,6 @@ void SoundEffect::PauseAll() { void SoundEffect::ResumeAll() { Mix_Resume(-1); } +bool SoundEffect::IsPlaying() const { + return Mix_Playing(m_Channel); +} diff --git a/Engine/SoundEffect.h b/Engine/SoundEffect.h index fbd4477..43252dd 100644 --- a/Engine/SoundEffect.h +++ b/Engine/SoundEffect.h @@ -20,6 +20,8 @@ public: static void PauseAll( ); static void ResumeAll( ); + bool IsPlaying() const; + private: Mix_Chunk* m_pMixChunk; int m_Channel; diff --git a/Engine/Text.cpp b/Engine/Text.cpp index 4f073db..36c23a5 100644 --- a/Engine/Text.cpp +++ b/Engine/Text.cpp @@ -31,3 +31,6 @@ void Text::ChangeText(const std::string& text) { std::cout << "This is wierd??: " << m_Text << std::endl; } } +std::string Text::GetText() { + return m_Text; +} diff --git a/Engine/Text.h b/Engine/Text.h index adfb558..261fb24 100644 --- a/Engine/Text.h +++ b/Engine/Text.h @@ -11,11 +11,15 @@ public: Text() = default; ~Text(); + Text(const Text& other) = delete; + Text(Text&& other) = delete; + Text& operator=(const Text& other) = delete; + Text& operator=(Text&& other) = delete; + void Draw(const Vector2f& pos) const; void ChangeText(const std::string& text); - - + std::string GetText(); private: std::string m_Text; diff --git a/Engine/colors.h b/Engine/colors.h index 4169914..00b356f 100644 --- a/Engine/colors.h +++ b/Engine/colors.h @@ -15,4 +15,6 @@ namespace Colors const Color4f CYAN{ 0.0f, 1.0f, 1.0f, 1.0f }; const Color4f PINK{ 1.0f, 0.0f, 0.5f, 1.0f }; const Color4f ORANGE{ 1.0f, 0.5f, 0.0f, 1.0f }; + const Color4f GRAY{ 0.5f, 0.5f, 0.5f, 1.0f}; + const Color4f LIGHTGRAY{ 0.8f, 0.8f, 0.8f, 1.0f}; } diff --git a/Game/Animations/Animation.cpp b/Game/Animations/Animation.cpp index dab1124..5359016 100644 --- a/Game/Animations/Animation.cpp +++ b/Game/Animations/Animation.cpp @@ -5,20 +5,20 @@ #include "utils.h" Animation::Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect, bool isLooping): m_pTexture(pTexture), m_SrcRect(srcRect), m_Frames(frames), - m_isLooping(isLooping), m_FrameDuration(frameDuration) { + m_IsLooping(isLooping), m_FrameDuration(frameDuration) { } void Animation::Update(float elapsedSec) { - if (m_isPlaying) { + if (m_IsPlaying) { m_FrameTimer -= elapsedSec; if (m_FrameTimer <= 0.0f) { m_FrameTimer = m_FrameDuration; ++m_CurrentFrame; if (m_CurrentFrame >= m_Frames) { m_CurrentFrame = 0; - if (!m_isLooping) { - m_hasPlayedOnce = true; - m_isPlaying = false; + if (!m_IsLooping) { + m_HasPlayedOnce = true; + m_IsPlaying = false; } } } @@ -32,22 +32,22 @@ void Animation::Draw(const Vector2f& pos, const Rectf& dst) const { Rectf src = m_SrcRect; src.left += static_cast(m_CurrentFrame) * src.width; - m_pTexture->Draw(dst, src, m_isFlipped); + m_pTexture->Draw(dst, src, m_IsFlipped); } void Animation::SetPlaying(bool isPlaying) { - m_isPlaying = isPlaying; + m_IsPlaying = isPlaying; } void Animation::SetFlipped(bool isFlipped) { - m_isFlipped = isFlipped; + m_IsFlipped = isFlipped; } void Animation::Reset() { m_CurrentFrame = 0; - m_hasPlayedOnce = false; - m_isPlaying = true; + m_HasPlayedOnce = false; + m_IsPlaying = true; m_FrameTimer = m_FrameDuration; } bool Animation::IsDone() const { - return m_hasPlayedOnce && !m_isLooping; + return m_HasPlayedOnce && !m_IsLooping; } int Animation::GetFrameCount() const { return m_Frames; diff --git a/Game/Animations/Animation.h b/Game/Animations/Animation.h index 0b2ab41..c3b75f0 100644 --- a/Game/Animations/Animation.h +++ b/Game/Animations/Animation.h @@ -5,6 +5,8 @@ class Animation { public: Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect, bool isLooping = true); + ~Animation() = default; + void Update(float elapsedSec); void Draw(const Vector2f& pos) const; @@ -30,9 +32,9 @@ private: float m_FrameDuration { 0.1f }; - bool m_isPlaying { true }; - bool m_isFlipped { false }; + bool m_IsPlaying { true }; + bool m_IsFlipped { false }; - bool m_isLooping { true }; - bool m_hasPlayedOnce { false }; + bool m_IsLooping { true }; + bool m_HasPlayedOnce { false }; }; diff --git a/Game/Camera.h b/Game/Camera.h index e372501..a488d23 100644 --- a/Game/Camera.h +++ b/Game/Camera.h @@ -9,9 +9,6 @@ public: Camera(const Vector2f& position, float scale = 1); ~Camera() = default; - Camera(const Camera& other) = default; - Camera& operator=(const Camera& other) = default; - void SetPosition(const Vector2f& position) { m_Position = position; } diff --git a/Game/Game.cpp b/Game/Game.cpp index f8afa7b..e4fd236 100644 --- a/Game/Game.cpp +++ b/Game/Game.cpp @@ -58,7 +58,7 @@ void Game::Draw() const { void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) { //std::cout << "KEYDOWN event: " << e.keysym.sym << std::endl; if(e.keysym.sym == SDLK_BACKQUOTE) { - m_imGui = !m_imGui; + m_ImGui = !m_ImGui; } } @@ -86,7 +86,7 @@ void Game::ProcessMouseWheelEvent(const SDL_MouseWheelEvent& e) { m_Camera.SetScale(newScale); } void Game::ProcessImGui() { - if(m_imGui) { + if(m_ImGui) { m_pCurrentLevel->ProcessImGui(); } } diff --git a/Game/Game.h b/Game/Game.h index 336f40d..bc7f3c1 100644 --- a/Game/Game.h +++ b/Game/Game.h @@ -47,6 +47,6 @@ private: bool m_IsRightMouseDown {}; - bool m_imGui{ true }; + bool m_ImGui{ true }; }; diff --git a/Game/Game.vcxproj b/Game/Game.vcxproj index 4724b62..000c662 100644 --- a/Game/Game.vcxproj +++ b/Game/Game.vcxproj @@ -459,9 +459,158 @@ true - + + MultiThreadedDebugDll + EnableFastChecks + Disabled + true + NoListing + x64\Debug\ + false + true + x64\Debug\ + Default + true + Column + false + Prompt + false + Sync + false + false + false + NotSet + Precise + true + false + false + false + Default + false + false + Default + Default + false + x64\Debug\ + x64\Debug\ + false + Neither + false + x64\Debug\ + Cdecl + x64\Debug\vc143.pdb + Use + pch.h + x64\Debug\Game.pch + false + false + false + true + false + false + x64\Debug\ + true + true + false + false + Default + x64\Debug\Game.tlog\ + false + true + false + true + true + Level3 + x64\Debug\ + EditAndContinue + false + false + false + InheritWarningLevel + true + false + _DEBUG;_CONSOLE;_UNICODE;UNICODE; + true + true + + + MultiThreadedDebugDll + EnableFastChecks + Disabled + true + NoListing + x64\Debug\ + false + true + x64\Debug\ + Default + true + Column + false + Prompt + false + Sync + false + false + false + NotSet + Precise + true + false + false + false + Default + false + false + Default + Default + false + x64\Debug\ + x64\Debug\ + false + Neither + false + x64\Debug\ + Cdecl + x64\Debug\vc143.pdb + Use + pch.h + x64\Debug\Game.pch + false + false + false + true + false + false + x64\Debug\ + true + true + false + false + Default + x64\Debug\Game.tlog\ + false + true + false + true + true + Level3 + x64\Debug\ + EditAndContinue + false + false + false + InheritWarningLevel + true + false + _DEBUG;_CONSOLE;_UNICODE;UNICODE; + true + true + + + MultiThreadedDebugDll EnableFastChecks @@ -634,9 +783,12 @@ - + + + + diff --git a/Game/GameManager.cpp b/Game/GameManager.cpp index ca3796b..0071042 100644 --- a/Game/GameManager.cpp +++ b/Game/GameManager.cpp @@ -3,16 +3,25 @@ GameManager* GameManager::m_pInstance = nullptr; + GameManager& GameManager::GetInstance() { if (m_pInstance == nullptr) { m_pInstance = new GameManager(); } return *m_pInstance; } +void GameManager::DestroyInstance() { + delete m_pInstance->m_pInventory; + delete m_pInstance->m_FuelLowSound; + delete m_pInstance; +} void GameManager::SetMainScreen(MainScreen* pMainScreen) { m_pMainScreen = pMainScreen; //TODO: not the best but ¯\_(ツ)_/¯ } +void GameManager::SetPlayer(Player* pPlayer) { + m_pPlayer = pPlayer; +} void GameManager::SetFuel(float fuel) { m_Fuel = fuel; //Limit to 0 - MAXa @@ -59,7 +68,32 @@ void GameManager::Update(float elapsedSecs) { m_pMainScreen->SetFuelMeterValue(this->GetMaxFuel() - m_Fuel); m_pMainScreen->SetHullMeterValue(m_HullIntegrity); m_pMainScreen->SetScore(std::to_string(m_Score)); + m_pMainScreen->SetMoney("$ " + std::to_string(m_Money)); + + if (m_HullIntegrity <= 0 or m_Fuel <= 0) { + m_pPlayer->Die(); + } + + if(m_Fuel <= 20) { + if(m_FuelLowSound->IsPlaying() == false) { + m_FuelLowSound->Play(1); + } + } } int GameManager::GetMaxFuel() { return 100; //TODO: change if i ever add upgrades } +PlayerInventory* GameManager::GetInventory() { + return m_pInventory; +} +Player* GameManager::GetPlayer() { + return m_pPlayer; +} +GameManager::GameManager() { + m_pInventory = new PlayerInventory(); + m_FuelLowSound = new SoundEffect{ "sound/fuel_low.wav" }; +} + + + + diff --git a/Game/GameManager.h b/Game/GameManager.h index cb365b3..78f984a 100644 --- a/Game/GameManager.h +++ b/Game/GameManager.h @@ -1,14 +1,17 @@ #pragma once #include "Player.h" #include "Gui/Screens/MainScreen.h" +#include "Inventory/PlayerInventory.h" class GameManager { public: static GameManager& GetInstance(); static GameManager* m_pInstance; + static void DestroyInstance(); void SetMainScreen(MainScreen* pMainScreen); + void SetPlayer(Player* pPlayer); //No time void SetFuel(float fuel); float GetFuel() const; @@ -29,9 +32,11 @@ public: void Update(float elapsedSecs); int GetMaxFuel(); + PlayerInventory* GetInventory(); + Player* GetPlayer(); private: - GameManager() = default; + GameManager(); float m_Balance{ 0.0f }; @@ -40,5 +45,11 @@ private: int m_Score{ 0 }; int m_Money{ 0 }; MainScreen* m_pMainScreen{ nullptr }; + PlayerInventory* m_pInventory{ nullptr }; + Player* m_pPlayer{ nullptr }; + + SoundEffect* m_FuelLowSound{ nullptr }; }; + + diff --git a/Game/GridSystem/WorldTile.cpp b/Game/GridSystem/WorldTile.cpp index f0213e7..839cba9 100644 --- a/Game/GridSystem/WorldTile.cpp +++ b/Game/GridSystem/WorldTile.cpp @@ -89,6 +89,7 @@ WorldTile::~WorldTile() { } void WorldTile::Draw() { + utils::SetColor(Colors::WHITE); switch (m_GroundTileType->GetType()) { case GroundTileTypes::Air: { diff --git a/Game/GridSystem/WorldTile.h b/Game/GridSystem/WorldTile.h index ae5ac82..8ffc73c 100644 --- a/Game/GridSystem/WorldTile.h +++ b/Game/GridSystem/WorldTile.h @@ -22,6 +22,7 @@ enum class GroundTileTypes { Iron, }; + static std::map GroundTileTypeStrings { { GroundTileTypes::Air, "Air" }, { GroundTileTypes::Dirt, "Dirt" }, @@ -35,6 +36,9 @@ static std::map GroundTileTypeStrings { }; + + + GroundTileType * getRandomGroundTile(); class GroundTileType { @@ -140,7 +144,7 @@ public: ~WorldTile(); void Draw(); - void Update(const Camera* camera); //TODO: no use + void Update(const Camera* camera); Vector2f GetPosition() const { return m_Position; diff --git a/Game/Gui/GuiButton.cpp b/Game/Gui/GuiButton.cpp index 2f47c4e..ef97b65 100644 --- a/Game/Gui/GuiButton.cpp +++ b/Game/Gui/GuiButton.cpp @@ -5,40 +5,34 @@ #include "colors.h" #include "utils.h" -GuiButton::GuiButton(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) { +GuiButton::GuiButton(const std::string& filePath, const Vector2f& pos, const Vector2f& size, bool shouldHideDefault, TextureManager* manager): m_Position(pos), m_Size(size), + m_shouldHide(shouldHideDefault) { m_Texture = manager->GetTexture(filePath); - if(size.x == 0 && size.y == 0) { - m_Size = Vector2f{float(m_Texture->GetWidth()), float(m_Texture->GetHeight())}; + if (size.x == 0 && size.y == 0) { + m_Size = Vector2f { float(m_Texture->GetWidth()), float(m_Texture->GetHeight()) }; } - std::cout << "Button created" << '\n'; -} -GuiButton::~GuiButton() { - std::cout << "Button destroyed" << '\n'; } void GuiButton::Draw() const { Rectf dest = Rectf(m_Position, m_Size); Rectf src = Rectf(0, 0, m_Texture->GetWidth(), m_Texture->GetHeight()); - if(m_IsHovered) { + if (m_IsHovered || !m_shouldHide) { m_Texture->Draw(dest, src, false); } } void GuiButton::Update(float elapsedSec) { Vector2f mousePos = utils::GetMousePos(); Rectf buttonRect = Rectf(m_Position, m_Size); - + this->m_IsHovered = utils::IsPointInRect(mousePos, buttonRect); - + m_IsPressed = m_IsHovered && utils::IsMouseButtonDown(SDL_BUTTON_LEFT); - if(m_IsPressed && !m_IsPrimed) { + if (m_IsPressed && !m_IsPrimed) { m_IsPrimed = true; m_OnClick(); } - if(!m_IsPressed) { + if (!m_IsPressed) { m_IsPrimed = false; } } - - - diff --git a/Game/Gui/GuiButton.h b/Game/Gui/GuiButton.h index 999871c..c3e9863 100644 --- a/Game/Gui/GuiButton.h +++ b/Game/Gui/GuiButton.h @@ -6,27 +6,31 @@ #include "Texture.h" #include "../TextureManager.h" -class GuiButton : public GuiElement -{ +class GuiButton : public GuiElement { public: GuiButton() = default; - GuiButton(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager); - ~GuiButton() override; + GuiButton(const std::string& filePath, const Vector2f& pos, const Vector2f& size, bool shouldHideDefault, TextureManager* manager); + ~GuiButton() override = default; virtual void Draw() const override; virtual void Update(float elapsedSec) override; void SetOnClick(std::function onClick) { m_OnClick = onClick; } - + private: - Texture* m_Texture{ nullptr }; + Texture* m_Texture { nullptr }; Vector2f m_Position; Vector2f m_Size; - bool m_IsHovered{ false }; - bool m_IsPressed{ false }; - bool m_IsPrimed{ false }; + bool m_IsHovered { false }; + bool m_IsPressed { false }; + bool m_IsPrimed { false }; - std::function m_OnClick{ []() { std::cout << "Button not implemented" << std::endl; } }; + bool m_shouldHide { true }; + + std::function m_OnClick { []() + { + std::cout << "Button not implemented" << std::endl; + } }; }; diff --git a/Game/Gui/GuiMeter.cpp b/Game/Gui/GuiMeter.cpp index 1dff68e..5df3509 100644 --- a/Game/Gui/GuiMeter.cpp +++ b/Game/Gui/GuiMeter.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "GuiMeter.h" +#include "colors.h" #include "TextureManager.h" #include "utils.h" GuiMeter::GuiMeter(const std::string& filePath, Vector2f pos, Vector2f frameSize, int frameCount, TextureManager* manager): GuiMeter( @@ -14,8 +15,9 @@ GuiMeter::~GuiMeter() { delete m_Animation; } void GuiMeter::Draw() const { + utils::SetColor(Colors::WHITE); m_Animation->Draw(m_Position, Rectf{m_Position, m_DrawSize}); - utils::DrawRect(Rectf { m_Position, m_DrawSize}); + // utils::DrawRect(Rectf { m_Position, m_DrawSize}); } void GuiMeter::Update(float elapsedSec) { const int frame = static_cast(utils::map(m_Value, 0.0f, m_MaxValue, 0, (float)m_Animation->GetFrameCount())); diff --git a/Game/Gui/GuiText.cpp b/Game/Gui/GuiText.cpp index 0e6808c..61ec18b 100644 --- a/Game/Gui/GuiText.cpp +++ b/Game/Gui/GuiText.cpp @@ -2,6 +2,7 @@ #include "GuiText.h" #include "colors.h" +#include "utils.h" GuiText::GuiText(const Vector2f& position, const std::string& text, const std::string& fontPath, int size, const Color4f& color): m_Position(position), m_Text(new Text(text, fontPath, size, color)) { } @@ -11,6 +12,7 @@ GuiText::GuiText(): m_Position(100,100), m_Text(new Text("Undefined", "fonts/ver } void GuiText::Draw() const { + utils::SetColor(Colors::WHITE); m_Text->Draw(m_Position); } @@ -20,6 +22,12 @@ void GuiText::Update(float elapsedSec) { void GuiText::ChangeText(const std::string& text) const { m_Text->ChangeText(text); } +void GuiText::SetPosition(const Vector2f& pos) { + m_Position = pos; +} GuiText::~GuiText() { delete m_Text; } +std::string GuiText::GetText() const { + return m_Text->GetText(); +} diff --git a/Game/Gui/GuiText.h b/Game/Gui/GuiText.h index 0b3d210..f0b89ca 100644 --- a/Game/Gui/GuiText.h +++ b/Game/Gui/GuiText.h @@ -8,12 +8,21 @@ public: GuiText(const Vector2f& position, const std::string& text, const std::string& fontPath, int size, const Color4f& color); GuiText(); + GuiText(const GuiText& other) = delete; + GuiText& operator=(const GuiText& other) = delete; + GuiText(GuiText&& other) = delete; + GuiText& operator=(GuiText&& other) = delete; + + void Draw() const override; void Update(float elapsedSec) override; void ChangeText(const std::string& text) const; + void SetPosition(const Vector2f& pos); ~GuiText() override; + std::string GetText() const; + private: Vector2f m_Position; Text* m_Text; diff --git a/Game/Gui/Screen.cpp b/Game/Gui/Screen.cpp index 7aed26a..a827b05 100644 --- a/Game/Gui/Screen.cpp +++ b/Game/Gui/Screen.cpp @@ -1,6 +1,9 @@ #include "pch.h" #include "Screen.h" +#include "colors.h" +#include "utils.h" + Screen::Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): m_Position(pos), m_Size(size) { if (!filePath.empty()) { m_Background = manager->GetTexture(filePath); @@ -23,6 +26,7 @@ void Screen::Update(float elapsedSecs) { } } void Screen::Draw() const { + utils::SetColor(Colors::WHITE); 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()); diff --git a/Game/Gui/Screen.h b/Game/Gui/Screen.h index 6e74b50..a21aafc 100644 --- a/Game/Gui/Screen.h +++ b/Game/Gui/Screen.h @@ -12,6 +12,11 @@ public: Screen() = default; Screen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager); + Screen(Screen& other) = delete; + Screen& operator=(Screen& other) = delete; + Screen(Screen&& other) = delete; + Screen& operator=(Screen&& other) = delete; + virtual ~Screen(); void AddElement(GuiElement* element); diff --git a/Game/Gui/Screens/FuelScreen.cpp b/Game/Gui/Screens/FuelScreen.cpp deleted file mode 100644 index f2b245c..0000000 --- a/Game/Gui/Screens/FuelScreen.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#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) -{ - const Vector2f fuelScreenSize = Vector2f { 492, 396 }; - // Vector2f fuelScreenCenter = Vector2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 }; - const Vector2f ScreenCenter = Vector2f { utils::GetViewport().x / 2, utils::GetViewport().y / 2 }; - - const Vector2f fuelScreenCenter = ScreenCenter - fuelScreenSize / 2; - - - const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 }; - Vector2f closeButtonPos = fuelScreenCenter + closeButtonOffset; - closeButtonPos.y -= 18; - GuiButton* closeFuelButton = new GuiButton { "gui/close.png", closeButtonPos, Vector2f{0,0}, TextureManager::GetInstance() }; - closeFuelButton->SetOnClick([this]() { ScreenManager::GetInstance()->CloseScreen(); }); - this->AddElement(closeFuelButton); - - const Vector2f oneDollarButtonPos = Vector2f { 451, 287 }; - GuiButton* fiveDollarButton = new GuiButton { "gui/fuel/5dollars.png", oneDollarButtonPos , Vector2f{0,0}, TextureManager::GetInstance() }; - this->AddElement(fiveDollarButton); - - const Vector2f tenDollarButtonPos = oneDollarButtonPos + Vector2f { 113, -1 }; - GuiButton* tenDollarButton = new GuiButton { "gui/fuel/10dollars.png", tenDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() }; - this->AddElement(tenDollarButton); - - const Vector2f twentyFiveDollarButtonPos = oneDollarButtonPos + Vector2f { 0, -89 }; - GuiButton* twentyFiveDollarButton = new GuiButton { "gui/fuel/25dollars.png", twentyFiveDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() }; - this->AddElement(twentyFiveDollarButton); - - const Vector2f fiftyDollarButtonPos = twentyFiveDollarButtonPos + Vector2f { 114, 0 }; - GuiButton* fiftyDollarButton = new GuiButton { "gui/fuel/50dollars.png", fiftyDollarButtonPos, Vector2f{0,0}, TextureManager::GetInstance() }; - this->AddElement(fiftyDollarButton); - - 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() { - 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())); -} diff --git a/Game/Gui/Screens/FuelScreen.h b/Game/Gui/Screens/FuelScreen.h deleted file mode 100644 index ca120ba..0000000 --- a/Game/Gui/Screens/FuelScreen.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once -#include "../Screen.h" -#include "Gui/GuiText.h" - -class FuelScreen : public Screen -{ -public: - - FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager); - virtual ~FuelScreen() override; - - virtual void Draw() const override; - virtual void Update(float elapsedSecs) override; - -private: - GuiText* m_MoneyText; - -}; diff --git a/Game/Gui/Screens/FuelScreen/FuelScreen.cpp b/Game/Gui/Screens/FuelScreen/FuelScreen.cpp new file mode 100644 index 0000000..808c162 --- /dev/null +++ b/Game/Gui/Screens/FuelScreen/FuelScreen.cpp @@ -0,0 +1,137 @@ +#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) { + const Vector2f fuelScreenSize { 492, 396 }; + const Vector2f ScreenCenter { utils::GetViewport().x / 2, utils::GetViewport().y / 2 }; + + const Vector2f fuelScreenCenter { ScreenCenter - fuelScreenSize / 2 }; + + m_BuySound = new SoundEffect { "sound/buy.wav" }; + + const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 }; + Vector2f closeButtonPos = fuelScreenCenter + closeButtonOffset; + closeButtonPos.y -= 18; + GuiButton* closeFuelButton = new GuiButton { "gui/close.png", closeButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() }; + closeFuelButton->SetOnClick([this]() + { + ScreenManager::GetInstance()->CloseScreen(); + }); + this->AddElement(closeFuelButton); + + const Vector2f oneDollarButtonPos = Vector2f { 451, 287 }; + GuiButton* fiveDollarButton = new GuiButton { "gui/fuel/5dollars.png", oneDollarButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() }; + fiveDollarButton->SetOnClick([this]() + { + if (GameManager::GetInstance().GetMoney() > 5) { + GameManager::GetInstance().AddFuel(5); + GameManager::GetInstance().IncreaseMoney(-5); + m_BuySound->Play(0); + } + else { + std::cout << "Not enough money" << std::endl; + } + }); + this->AddElement(fiveDollarButton); + + const Vector2f tenDollarButtonPos = oneDollarButtonPos + Vector2f { 113, -1 }; + GuiButton* tenDollarButton = new GuiButton { "gui/fuel/10dollars.png", tenDollarButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() }; + tenDollarButton->SetOnClick([this]() + { + if (GameManager::GetInstance().GetMoney() > 10) { + GameManager::GetInstance().AddFuel(10); + GameManager::GetInstance().IncreaseMoney(-10); + m_BuySound->Play(0); + } + else { + std::cout << "Not enough money" << std::endl; + } + }); + this->AddElement(tenDollarButton); + + const Vector2f twentyFiveDollarButtonPos = oneDollarButtonPos + Vector2f { 0, -89 }; + GuiButton* twentyFiveDollarButton = new GuiButton { "gui/fuel/25dollars.png", twentyFiveDollarButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() }; + twentyFiveDollarButton->SetOnClick([this]() + { + if (GameManager::GetInstance().GetMoney() > 25) { + GameManager::GetInstance().AddFuel(25); + GameManager::GetInstance().IncreaseMoney(-25); + m_BuySound->Play(0); + } + else { + std::cout << "Not enough money" << std::endl; + } + }); + this->AddElement(twentyFiveDollarButton); + + const Vector2f fiftyDollarButtonPos = twentyFiveDollarButtonPos + Vector2f { 114, 0 }; + GuiButton* fiftyDollarButton = new GuiButton { "gui/fuel/50dollars.png", fiftyDollarButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() }; + fiftyDollarButton->SetOnClick([this]() + { + if (GameManager::GetInstance().GetMoney() > 50) { + GameManager::GetInstance().AddFuel(50); + GameManager::GetInstance().IncreaseMoney(-50); + m_BuySound->Play(0); + + } + else { + std::cout << "Not enough money" << std::endl; + } + }); + this->AddElement(fiftyDollarButton); + + const Vector2f fillTankButtonPos = Vector2f { 450, 108 }; + GuiButton* fillTankButton = new GuiButton { "gui/fuel/fillTank.png", fillTankButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() }; + fillTankButton->SetOnClick([this]() + { + if (GameManager::GetInstance().GetFuel() < GameManager::GetInstance().GetMaxFuel() - 2) { + int fuelNeeded = static_cast(GameManager::GetInstance().GetMaxFuel() - GameManager::GetInstance().GetFuel()); + if (fuelNeeded <= GameManager::GetInstance().GetMoney()) { + GameManager::GetInstance().AddFuel(fuelNeeded); + GameManager::GetInstance().IncreaseMoney(-fuelNeeded); + m_BuySound->Play(0); + } + else { + std::cout << "Not enough money" << std::endl; + } + } + else { + std::cout << "Don't need fuel" << std::endl; + } + }); + this->AddElement(fillTankButton); + + + Vector2f offset { 50, 320 }; + m_MoneyText = new GuiText { fuelScreenCenter + offset, "$ 20", "fonts/Arial.ttf", 20, Colors::YELLOW }; + +} + +FuelScreen::~FuelScreen() { + delete m_MoneyText; + delete m_BuySound; +}; + +void FuelScreen::Draw() const { + + int currentFuel = GameManager::GetInstance().GetFuel(); + int maxFuel = GameManager::GetInstance().GetMaxFuel(); + + utils::SetColor(Color4f { 99.f / 255.f, 82.f / 255.f, 36.f / 255.f, 1.f }); + 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())); //Not the best but will work +} diff --git a/Game/Gui/Screens/FuelScreen/FuelScreen.h b/Game/Gui/Screens/FuelScreen/FuelScreen.h new file mode 100644 index 0000000..e986b07 --- /dev/null +++ b/Game/Gui/Screens/FuelScreen/FuelScreen.h @@ -0,0 +1,25 @@ +#pragma once +#include "SoundEffect.h" +#include "../../Screen.h" +#include "Gui/GuiText.h" + +class FuelScreen final : public Screen { +public: + FuelScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager); + virtual ~FuelScreen() override; + + FuelScreen(const FuelScreen& other) = delete; + FuelScreen(FuelScreen&& other) = delete; + FuelScreen& operator=(const FuelScreen& other) = delete; + FuelScreen& operator=(FuelScreen&& other) = delete; + + + virtual void Draw() const override; + virtual void Update(float elapsedSecs) override; + +private: + GuiText* m_MoneyText; + + SoundEffect* m_BuySound { nullptr }; + +}; diff --git a/Game/Gui/Screens/MainScreen.cpp b/Game/Gui/Screens/MainScreen.cpp index f2f1bfa..4dbf987 100644 --- a/Game/Gui/Screens/MainScreen.cpp +++ b/Game/Gui/Screens/MainScreen.cpp @@ -5,24 +5,55 @@ #include "GameManager.h" #include "utils.h" #include "Gui/GuiText.h" -MainScreen::MainScreen(TextureManager* manager) : Screen("", Vector2f{0, 0}, Vector2f{900.f, 500.f}, manager) { +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); + 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); + 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}; + 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); + Vector2f ScoreMeterPosition { 150, ScreenSize.y - 50 }; + m_ScoreText = new GuiText(ScoreMeterPosition, "0", "fonts/Arial.ttf", 20, Colors::YELLOW); this->AddElement(m_ScoreText); + + + Vector2f InvButtonPosition { ScreenSize.x - 150, ScreenSize.y - 60 }; + float InvButtonScale = 1.2f; + m_InvButton = new GuiButton("gui/main/inv.png", InvButtonPosition, Vector2f { 58 * InvButtonScale, 55 * InvButtonScale }, false, manager); + m_InvButton->SetOnClick([]() + { + // GameManager::GetInstance().ToggleInventory(); + std::cout << "Inventory button clicked" << std::endl; + }); + this->AddElement(m_InvButton); + + Vector2f OptionsButtonPosition { ScreenSize.x - 85, ScreenSize.y - 85 }; + m_OptionsButton = new GuiButton("gui/main/options.png", OptionsButtonPosition, Vector2f { 74, 56 }, false, manager); + m_OptionsButton->SetOnClick([]() + { + // GameManager::GetInstance().ToggleOptions(); + std::cout << "Options button clicked" << std::endl; + }); + this->AddElement(m_OptionsButton); + + m_HelpButton = new GuiButton("gui/main/help.png", Vector2f { ScreenSize.x - 50, ScreenSize.y - 50 }, Vector2f { 50, 50 }, false, manager); + m_HelpButton->SetOnClick([]() + { + // GameManager::GetInstance().ToggleHelp(); + std::cout << "Help button clicked" << std::endl; + }); + this->AddElement(m_HelpButton); + + m_MoneyText = new GuiText(Vector2f { ScreenSize.x - 450, ScreenSize.y - 35 }, "Filler Text", "fonts/Arial.ttf", 25, Colors::YELLOW); + this->AddElement(m_MoneyText); } MainScreen::~MainScreen() = default; void MainScreen::Draw() const { @@ -43,4 +74,6 @@ void MainScreen::SetDepth(const std::string& text) const { void MainScreen::SetScore(const std::string& text) const { m_ScoreText->ChangeText(text); } - +void MainScreen::SetMoney(const std::string& text) const { + m_MoneyText->ChangeText(text); +} diff --git a/Game/Gui/Screens/MainScreen.h b/Game/Gui/Screens/MainScreen.h index 9141fa8..f7a2a2b 100644 --- a/Game/Gui/Screens/MainScreen.h +++ b/Game/Gui/Screens/MainScreen.h @@ -3,7 +3,7 @@ #include "Gui/GuiText.h" #include "Gui/Screen.h" -class MainScreen: public Screen { +class MainScreen final : public Screen { public: explicit MainScreen(TextureManager* manager); virtual ~MainScreen() override; @@ -16,6 +16,7 @@ public: void SetDepth(const std::string& text) const; void SetScore(const std::string& text) const; + void SetMoney(const std::string& text) const; private: GuiMeter* m_FuelMeter; @@ -23,5 +24,10 @@ private: GuiText* m_DepthText; GuiText* m_ScoreText; - + GuiText* m_MoneyText; + + GuiButton* m_InvButton; + GuiButton* m_OptionsButton; + GuiButton* m_HelpButton; + }; diff --git a/Game/Gui/Screens/ScreenManager.cpp b/Game/Gui/Screens/ScreenManager.cpp index 4cca990..9b186c1 100644 --- a/Game/Gui/Screens/ScreenManager.cpp +++ b/Game/Gui/Screens/ScreenManager.cpp @@ -1,20 +1,21 @@ #include "pch.h" #include "ScreenManager.h" -#include "FuelScreen.h" +#include "FuelScreen/FuelScreen.h" +#include "SellScreen/SellScreen.h" #include "utils.h" ScreenManager* ScreenManager::m_pInstance = nullptr; -Screen* ScreenManager::m_FuelScreen{ nullptr }; -Screen* ScreenManager::m_SellScreen{ nullptr }; +Screen* ScreenManager::m_FuelScreen { nullptr }; +Screen* ScreenManager::m_SellScreen { nullptr }; -ScreenManager* ScreenManager::GetInstance() { +ScreenManager * ScreenManager::GetInstance() { - if(m_pInstance == nullptr) { + if (m_pInstance == nullptr) { m_pInstance = new ScreenManager(); } - if(!m_pInstance->m_AreScreensInitialized) { - m_pInstance->InitializeScreens(); //TODO: Ask if this a hack + if (!m_pInstance->m_AreScreensInitialized) { + m_pInstance->InitializeScreens(); m_pInstance->m_AreScreensInitialized = true; } return m_pInstance; @@ -25,19 +26,19 @@ void ScreenManager::DestroyInstance() { } void ScreenManager::OpenScreen(Screen* screen) { - if(m_IsScreenOpen == false) { + if (m_IsScreenOpen == false) { m_currentScreen = screen; m_IsScreenOpen = true; } } void ScreenManager::CloseScreen() { - if(m_IsScreenOpen == true) { + if (m_IsScreenOpen == true) { m_IsScreenOpen = false; m_currentScreen = nullptr; } } -bool ScreenManager::IsScreenOpen() { +bool ScreenManager::IsScreenOpen() const { return m_IsScreenOpen; } ScreenManager::~ScreenManager() { @@ -51,8 +52,7 @@ void ScreenManager::InitializeScreens() { Vector2f sellScreenSize = Vector2f { 533, 398 }; Vector2f sellScreenCenter = Vector2f { utils::GetViewport().x / 2 - sellScreenSize.x / 2, utils::GetViewport().y / 2 - sellScreenSize.y / 2 }; - m_SellScreen = new Screen { "gui/sell/background.png", sellScreenCenter, sellScreenSize, TextureManager::GetInstance() }; - + m_SellScreen = new SellScreen { "gui/sell/background.png", sellScreenCenter, sellScreenSize, 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 cf7f210..6361989 100644 --- a/Game/Gui/Screens/ScreenManager.h +++ b/Game/Gui/Screens/ScreenManager.h @@ -3,8 +3,7 @@ -class ScreenManager -{ +class ScreenManager { public: static ScreenManager* GetInstance(); static void DestroyInstance(); @@ -12,23 +11,26 @@ public: void OpenScreen(Screen* screen); void CloseScreen(); - Screen* GetCurrentScreen() const { return m_currentScreen; } - bool IsScreenOpen(); + Screen * GetCurrentScreen() const { + return m_currentScreen; + } + bool IsScreenOpen() const; static ScreenManager* m_pInstance; static Screen* m_FuelScreen; static Screen* m_SellScreen; + private: ScreenManager() = default; ~ScreenManager(); void InitializeScreens(); - - bool m_IsScreenOpen{ false }; + + bool m_IsScreenOpen { false }; Screen* m_currentScreen; - bool m_AreScreensInitialized{ false }; - -}; \ No newline at end of file + bool m_AreScreensInitialized { false }; + +}; diff --git a/Game/Gui/Screens/SellScreen/SellScreen.cpp b/Game/Gui/Screens/SellScreen/SellScreen.cpp new file mode 100644 index 0000000..c06699a --- /dev/null +++ b/Game/Gui/Screens/SellScreen/SellScreen.cpp @@ -0,0 +1,116 @@ +#include "pch.h" +#include "SellScreen.h" + +#include "colors.h" +#include "GameManager.h" +#include "SellSreenRow.h" +#include "../ScreenManager.h" +#include "utils.h" +SellScreen::SellScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager): Screen(filePath, pos, size, manager) { + const Vector2f sellScreenSize { 492, 396 }; + // Vector2f fuelScreenCenter = Vector2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 }; + const Vector2f ScreenCenter = Vector2f { utils::GetViewport().x / 2, utils::GetViewport().y / 2 }; + + const Vector2f sellScreenCenter = ScreenCenter - sellScreenSize / 2; + + const Vector2f closeButtonOffset = Vector2f { 460, 396 - 14 }; + Vector2f closeButtonPos = sellScreenCenter + closeButtonOffset; + closeButtonPos.y -= 18; + GuiButton* closeFuelButton = new GuiButton { "gui/close.png", closeButtonPos, Vector2f { 0, 0 }, true, TextureManager::GetInstance() }; + closeFuelButton->SetOnClick([this]() + { + ScreenManager::GetInstance()->CloseScreen(); + }); + this->AddElement(closeFuelButton); + + std::string HeaderText = "Cargo Bay Qty. Value Total Value"; //Dont ask + Vector2f headerTextPos = Vector2f { 285, 400 }; + GuiText* m_HeaderText = new GuiText { headerTextPos, HeaderText, "fonts/Arial.ttf", 14, Colors::LIGHTGRAY }; + this->AddElement(m_HeaderText); + + + std::string sellAllPath = "gui/sell/sellall.png"; + Vector2f sellAllPos = Vector2f { 410, 100 }; + + GuiButton* sellAllButton = new GuiButton { sellAllPath, sellAllPos, Vector2f { 97, 27 }, false, TextureManager::GetInstance() }; + sellAllButton->SetOnClick([this]() + { + this->SellAll(); + }); + this->AddElement(sellAllButton); + + std::string totalSell = "Balls"; + Vector2f totalSellPos = Vector2f { 590, 105 }; + m_TotalMoneyText = new GuiText { totalSellPos, totalSell, "fonts/Arial.ttf", 18, Colors::GREEN }; + this->AddElement(m_TotalMoneyText); +} +SellScreen::~SellScreen() { + for (SellSreenRow* row : m_Rows) { + delete row; + } +} +void SellScreen::Draw() const { + Screen::Draw(); + for (const SellSreenRow* row : m_Rows) { + row->Draw(); + } + + // m_TotalMoneyText->Draw(); + utils::SetColor(Colors::GREEN); + utils::DrawLine(550, 130, 650, 130); + +} +void SellScreen::Update(float elapsedSecs) { + Screen::Update(elapsedSecs); + if (m_AreRowsDirty) { + //remake rows + m_AreRowsDirty = false; + + for (SellSreenRow* row : m_Rows) { + delete row; + } + m_Rows.clear(); + + std::vector items = GameManager::GetInstance().GetInventory()->GetItems(); + int totalWorth { 0 }; + int index { 0 }; //Fix to not overshoot when an empty item is in the inventory + for (ItemStack* item : items) { + if (item->m_ItemType == InventoryItem::Empty) { + continue; + } + SellSreenRow* row = new SellSreenRow(*item, Vector2f { 250, (float)360 - index * 30 }, Vector2f { 400, 30 }); + totalWorth += item->m_Quantity * PlayerInventory::GetItemValue(item->m_ItemType); + m_Rows.push_back(std::move(row)); + index++; + } + + + m_TotalMoneyText->ChangeText("$" + std::to_string(GameManager::GetInstance().GetInventory()->GetTotalValue())); + int characterCount = m_TotalMoneyText->GetText().length(); + m_TotalMoneyText->SetPosition(Vector2f { (float)610 - characterCount * 10, 105 }); + } + + for (SellSreenRow* row : m_Rows) { + row->Update(elapsedSecs); + } +} +void SellScreen::MarkDirty() { + m_AreRowsDirty = true; +} +void SellScreen::SellAll() { + PlayerInventory* inventory = GameManager::GetInstance().GetInventory(); + std::vector items = inventory->GetItems(); + if (items.empty()) { + return; + } + + int totalWorth { 0 }; + for (ItemStack* item : items) { + if (item->m_ItemType == InventoryItem::Empty) { + continue; + } + totalWorth += item->m_Quantity * PlayerInventory::GetItemValue(item->m_ItemType); + inventory->RemoveItem(item); + } + GameManager::GetInstance().IncreaseMoney(totalWorth); +} diff --git a/Game/Gui/Screens/SellScreen/SellScreen.h b/Game/Gui/Screens/SellScreen/SellScreen.h new file mode 100644 index 0000000..22f5d2c --- /dev/null +++ b/Game/Gui/Screens/SellScreen/SellScreen.h @@ -0,0 +1,23 @@ +#pragma once +#include "SellSreenRow.h" +#include "../../Screen.h" +#include "Gui/GuiText.h" + +class SellScreen final : public Screen { +public: + SellScreen(const std::string& filePath, Vector2f pos, Vector2f size, TextureManager* manager); + virtual ~SellScreen() override; + + virtual void Draw() const override; + virtual void Update(float elapsedSecs) override; + + void MarkDirty(); + void SellAll(); + +private: + GuiText* m_TotalMoneyText; + + std::vector m_Rows; + + bool m_AreRowsDirty { true }; +}; diff --git a/Game/Gui/Screens/SellScreen/SellSreenRow.cpp b/Game/Gui/Screens/SellScreen/SellSreenRow.cpp new file mode 100644 index 0000000..ca5fe8e --- /dev/null +++ b/Game/Gui/Screens/SellScreen/SellSreenRow.cpp @@ -0,0 +1,45 @@ +#include "pch.h" +#include "SellSreenRow.h" + +#include "colors.h" +#include "utils.h" +SellSreenRow::SellSreenRow(const ItemStack& item, const Vector2f& pos, const Vector2f& size): m_Item(item), m_Pos(pos), m_Size(size) { + m_NameText = new Text(PlayerInventory::GetItemName(item.m_ItemType), "fonts/verdana.ttf", 12, Colors::GREEN); + m_CalculationText = new Text("Hello World", "fonts/verdana.ttf", 14, Colors::GREEN); + this->GenerateCalcString(); + m_Icon = PlayerInventory::GetItemIcon(item.m_ItemType); +} +SellSreenRow::~SellSreenRow() { + delete m_NameText; + delete m_CalculationText; +} +void SellSreenRow::Draw() const { + //The row has, The icon, The name, The amount, an X, the value, an =, the total value + //The icon + + Vector2f iconPos { m_Pos.x + 10, m_Pos.y + 2 }; + m_Icon->Draw(iconPos); + //The name + Vector2f namePos { iconPos.x + 50, m_Pos.y + 8 }; + m_NameText->Draw(namePos); + + Vector2f amountPos { namePos.x + 100, m_Pos.y + 8 }; + m_CalculationText->Draw(amountPos); + + utils::SetColor(Colors::GREEN); + utils::DrawRect(Rectf { m_Pos, m_Size }); +} +void SellSreenRow::Update(float elapsedSecs) { + // m_NameText->ChangeText("EXAMPLE"); + // m_CalculationText->ChangeText(std::to_string(m_Item.m_Quantity)); + GenerateCalcString(); + +} +void SellSreenRow::GenerateCalcString() { + std::string amount = std::to_string(m_Item.m_Quantity); + std::string value = std::to_string(PlayerInventory::GetItemValue(m_Item.m_ItemType)); + std::string totalValue = std::to_string(PlayerInventory::GetItemValue(m_Item.m_ItemType) * m_Item.m_Quantity); + // NAME AMOUNT X VALUE = TOTAL VALUE + std::string text = amount + " x $" + value + " = " + totalValue + "$"; + m_CalculationText->ChangeText(text); +} diff --git a/Game/Gui/Screens/SellScreen/SellSreenRow.h b/Game/Gui/Screens/SellScreen/SellSreenRow.h new file mode 100644 index 0000000..94f9ae9 --- /dev/null +++ b/Game/Gui/Screens/SellScreen/SellSreenRow.h @@ -0,0 +1,32 @@ +#pragma once +#include "Text.h" +#include "TextureManager.h" +#include "Inventory/PlayerInventory.h" + +class SellSreenRow { +public: + SellSreenRow(const ItemStack& item, const Vector2f& pos, const Vector2f& size); + ~SellSreenRow(); + + SellSreenRow(const SellSreenRow& other) = delete; + SellSreenRow(SellSreenRow&& other) = delete; + SellSreenRow& operator=(const SellSreenRow& other) = delete; + SellSreenRow& operator=(SellSreenRow&& other) = delete; + + void Draw() const; + void Update(float elapsedSecs); + +private: + void GenerateCalcString(); + + ItemStack m_Item; + Vector2f m_Pos; + Vector2f m_Size; + + Text* m_NameText; + Text* m_CalculationText; + + Texture* m_Icon; + + +}; diff --git a/Game/Inventory/PlayerInventory.cpp b/Game/Inventory/PlayerInventory.cpp new file mode 100644 index 0000000..c537093 --- /dev/null +++ b/Game/Inventory/PlayerInventory.cpp @@ -0,0 +1,130 @@ +#include "pch.h" +#include "PlayerInventory.h" + +#include + +#include "Gui/Screens/ScreenManager.h" +#include "Gui/Screens/SellScreen/SellScreen.h" +PlayerInventory::PlayerInventory() { +} +PlayerInventory::~PlayerInventory() { + for(ItemStack* stack : m_Items) { + delete stack; + } +} +void PlayerInventory::ClearInventory() { + for (ItemStack* stack : m_Items) { + delete stack; + } +} +int PlayerInventory::GetTotalValue() const { + int totalValue{ 0 }; + for (ItemStack* stack : m_Items) { + totalValue += stack->m_Quantity * GetItemValue(stack->m_ItemType); + } + return totalValue; +} +void PlayerInventory::AddItem(const ItemStack& item) { + dynamic_cast(ScreenManager::m_SellScreen)->MarkDirty(); + //Check if its in the array + for(ItemStack* stack : m_Items) { + if(stack->m_ItemType == item.m_ItemType) { + std::cout << "Added item to inventory: Existing Array" << std::endl; + stack->m_Quantity += item.m_Quantity; + if(stack->m_Quantity == 2){} + return; + } + } + + m_Items.push_back(new ItemStack(item)); + std::cout << "Added item to inventory: New Item" << std::endl; + + +} +void PlayerInventory::RemoveItem(ItemStack* item) { + //Remove the item + for (size_t i = 0; i < m_Items.size(); i++) { + if(m_Items[i] == item) { + delete m_Items[i]; + m_Items.erase(m_Items.begin() + i); + dynamic_cast(ScreenManager::m_SellScreen)->MarkDirty(); + return; + } + } +} +std::vector PlayerInventory::GetItems() const { + return m_Items; +} +InventoryItem PlayerInventory::GetItemByType(GroundTileType* tile) { + if(tile == nullptr) { + return InventoryItem::Empty; + } + switch (tile->GetType()) { + case GroundTileTypes::Bronze: + return InventoryItem::Bronzium; + case GroundTileTypes::Air: + return InventoryItem::Empty; + case GroundTileTypes::Gold: + return InventoryItem::Goldium; + case GroundTileTypes::Iron: + return InventoryItem::Ironium; + default: + return InventoryItem::Empty; + } +} +std::string PlayerInventory::GetItemName(InventoryItem item) { + switch (item) { + case InventoryItem::Bronzium: + return "Bronzium"; + case InventoryItem::Diamond: + return "Diamond"; + case InventoryItem::Einsteinium: + return "Einsteinium"; + case InventoryItem::Emerald: + return "Emerald"; + case InventoryItem::Goldium: + return "Goldium"; + case InventoryItem::Ironium: + return "Ironium"; + case InventoryItem::Platnium: + return "Platnium"; + case InventoryItem::Ruby: + return "Ruby"; + case InventoryItem::Silverium: + return "Silverium"; + case InventoryItem::Special: + return "Special"; + default: + return "Empty"; + } +} +int PlayerInventory::GetItemValue(InventoryItem item) { + switch(item) { + case InventoryItem::Bronzium: + return 60; + case InventoryItem::Ironium: + return 30; + case InventoryItem::Silverium: + return 100; + case InventoryItem::Goldium: + return 250; + case InventoryItem::Platinum: + return 750; + case InventoryItem::Einsteinium: + return 2000; + case InventoryItem::Emerald: + return 5000; + case InventoryItem::Ruby: + return 20000; + case InventoryItem::Diamond: + return 100000; + default: + return 0; + } +} +Texture* PlayerInventory::GetItemIcon(InventoryItem item) { + std::string texturePath = "gui/sell/icons/"; + std::string itemName = GetItemName(item); + texturePath += itemName + ".png"; + return TextureManager::GetInstance()->GetTexture(texturePath); +} diff --git a/Game/Inventory/PlayerInventory.h b/Game/Inventory/PlayerInventory.h new file mode 100644 index 0000000..ccda46d --- /dev/null +++ b/Game/Inventory/PlayerInventory.h @@ -0,0 +1,51 @@ +#pragma once +#include + +#include "GridSystem/WorldTile.h" + + +enum class InventoryItem { + Empty, + Bronzium, + Diamond, + Einsteinium, + Emerald, + Goldium, + Ironium, + Platinum, + Platnium, + Ruby, + Silverium, + Special, +}; + +struct ItemStack { + ItemStack(InventoryItem type, int quantity) : m_ItemType{ type }, m_Quantity{ quantity } {} + InventoryItem m_ItemType; + int m_Quantity{ 0 }; +}; + +class PlayerInventory final { +public: + PlayerInventory(); + ~PlayerInventory(); + + PlayerInventory(PlayerInventory& other) = delete; + PlayerInventory& operator=(PlayerInventory& other) = delete; + PlayerInventory(PlayerInventory&& other) = delete; + PlayerInventory& operator=(PlayerInventory&& other) = delete; + + void ClearInventory(); + int GetTotalValue() const; + void AddItem(const ItemStack& item); + void RemoveItem(ItemStack* item); + std::vector GetItems() const; + InventoryItem GetItemByType(GroundTileType* tile); + static std::string GetItemName(InventoryItem item); + static int GetItemValue(InventoryItem item); + static Texture* GetItemIcon(InventoryItem item); + + +private: + std::vector m_Items; +}; diff --git a/Game/Levels/Level.h b/Game/Levels/Level.h index 065ae46..0bf8b86 100644 --- a/Game/Levels/Level.h +++ b/Game/Levels/Level.h @@ -11,6 +11,8 @@ public: Level(const Level& other) = default; Level(Level&& other) = default; + Level& operator=(const Level& other) = default; + Level& operator=(Level&& other) = default; virtual void Update(float elapsedSec) = 0; virtual void Draw() const = 0; diff --git a/Game/Levels/World/Building.cpp b/Game/Levels/World/Building.cpp index a3eb75f..73f770f 100644 --- a/Game/Levels/World/Building.cpp +++ b/Game/Levels/World/Building.cpp @@ -5,16 +5,16 @@ #include #include "colors.h" +#include "GameManager.h" +#include "Player.h" #include "utils.h" Building::Building(const std::string& filePath, const Vector2f& position, const Rectf& boundingBox, TextureManager* pTextureManager): m_Position(position), m_BoundingBox(boundingBox) { m_Texture = pTextureManager->GetTexture(filePath); m_Size = Vector2f(m_Texture->GetWidth(), m_Texture->GetHeight()); - std::cout << "i like kids" << std::endl; } -Building::~Building() = default; - void Building::Draw() const { + utils::SetColor(Colors::WHITE); m_Texture->Draw(m_Position); utils::SetColor(Colors::GREEN); Rectf temp = m_BoundingBox; @@ -24,15 +24,20 @@ void Building::Draw() const { } void Building::Update(float dt, const Rectf& objectBoundingBox) { if (IsObjectInHitbox(objectBoundingBox)) { - if (!m_IsPlayerInHitbox) { //TODO: what - m_IsPlayerInHitbox = true; - if (m_OnEnterHitbox != nullptr) { - m_OnEnterHitbox(); - } - else { - std::cout << "No function set for onEnterHitbox" << std::endl; + Player* player = GameManager::GetInstance().GetPlayer(); + float speed = player->GetVelocity().Length(); + if (speed < 100.0f) { + if (!m_IsPlayerInHitbox) { + m_IsPlayerInHitbox = true; + if (m_OnEnterHitbox != nullptr) { + m_OnEnterHitbox(); + } + else { + std::cout << "No function set for onEnterHitbox" << std::endl; + } } } + } else { m_IsPlayerInHitbox = false; diff --git a/Game/Levels/World/Building.h b/Game/Levels/World/Building.h index 9227331..5f6e49e 100644 --- a/Game/Levels/World/Building.h +++ b/Game/Levels/World/Building.h @@ -8,12 +8,8 @@ class Building { public: Building(const std::string& filePath, const Vector2f& position, const Rectf& boundingBox, TextureManager* pTextureManager); - // Building(const Building& other) = default; - // Building(Building&& other) = default; - // Building& operator=(const Building& other) = default; - // Building& operator=(Building&& other) = default; - ~Building(); + ~Building() = default; void Draw() const; void Update(float dt, const Rectf& objectBoundingBox); diff --git a/Game/Levels/World/WorldLevel.cpp b/Game/Levels/World/WorldLevel.cpp index 3bdfa20..a498cf5 100644 --- a/Game/Levels/World/WorldLevel.cpp +++ b/Game/Levels/World/WorldLevel.cpp @@ -46,8 +46,11 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera), m_GridManager.GetTileAtWorldPos(Vector2f { -650, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE); m_GridManager.GetTileAtWorldPos(Vector2f { -600, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT); - - m_Buildings.emplace_back(new Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, Rectf{0 ,0, 100, 100}, TextureManager::GetInstance() }); + Building* mineralBuilding = new Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, Rectf{0 ,0, 100, 100}, TextureManager::GetInstance() }; + mineralBuilding->SetOnEnterHitbox([]() { + ScreenManager::GetInstance()->OpenScreen(ScreenManager::m_SellScreen); + }); + m_Buildings.emplace_back(mineralBuilding); m_GridManager.GetTileAtWorldPos(Vector2f {-400, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT); m_GridManager.GetTileAtWorldPos(Vector2f {-350, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE); m_GridManager.GetTileAtWorldPos(Vector2f {-300, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE); @@ -70,7 +73,7 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera), m_GridManager.GetTileAtWorldPos(Vector2f {800, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT); - m_topCover = TextureManager::GetInstance()->GetTexture("topBackground.png"); + m_TopCover = TextureManager::GetInstance()->GetTexture("topBackground.png"); m_MainScreen = new MainScreen(TextureManager::GetInstance()); GameManager::GetInstance().SetMainScreen(m_MainScreen); @@ -80,13 +83,28 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera), GameManager::GetInstance().SetFuel(100); GameManager::GetInstance().SetHullIntegrity(100); + + GameManager::GetInstance().SetPlayer(&m_Player); + + m_BackgroundMusic = new SoundStream("sound/bgm.wav"); + m_BackgroundMusic->Play(0); } WorldLevel::~WorldLevel() { delete m_MainScreen; delete m_Sun; delete m_Moon; + + delete m_BackgroundMusic; + + for (Building* building : m_Buildings) { + delete building; + } + + GameManager::DestroyInstance(); + } + void WorldLevel::Update(float elapsedSec) { m_Fps = 1 / elapsedSec; @@ -156,7 +174,7 @@ void WorldLevel::Update(float elapsedSec) { GameManager::GetInstance().Update(elapsedSec); m_MainScreen->SetDepth(std::to_string((int)-m_Player.GetPosition().y - 50) + " ft."); - m_MainScreen->SetScore("Score: " + std::to_string(GameManager::GetInstance().GetScore())); + m_MainScreen->SetScore(std::to_string(GameManager::GetInstance().GetScore())); // m_MainScreen->SetFuelMeterValue(GameManager::GetInstance().GetFuel()); // m_MainScreen->SetHullMeterValue(GameManager::GetInstance().GetHullIntegrity()); m_MainScreen->Update(elapsedSec); @@ -178,7 +196,7 @@ void WorldLevel::Draw() const { m_Moon->Draw(); // m_topCover->Draw(Vector2f{-850,-70} ); - m_topCover->Draw(Rectf{-850, -70, 850, -70 + 32}, Rectf{0, 0, WORLD_WIDTH * 50, 32}); + 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); diff --git a/Game/Levels/World/WorldLevel.h b/Game/Levels/World/WorldLevel.h index 76546bb..de26c50 100644 --- a/Game/Levels/World/WorldLevel.h +++ b/Game/Levels/World/WorldLevel.h @@ -8,6 +8,7 @@ #include "Camera.h" #include "OrbitingObject.h" #include "SoundEffect.h" +#include "SoundStream.h" #include "Text.h" #include "Gui/GuiMeter.h" #include "Gui/Screens/MainScreen.h" @@ -19,8 +20,12 @@ public: WorldLevel(Camera* camera, Rectf viewport); virtual ~WorldLevel() override; - WorldLevel(const WorldLevel& other) = default; - WorldLevel(WorldLevel&& other) = default; + WorldLevel(const WorldLevel& other) = delete; + WorldLevel& operator=(const WorldLevel& other) = delete; + WorldLevel(WorldLevel&& other) = delete; + WorldLevel& operator=(WorldLevel&& other) = delete; + + void Update(float elapsedSec) override; void Draw() const override; @@ -40,6 +45,8 @@ private: Player m_Player; Vector2f m_MousePos {}; + SoundStream* m_BackgroundMusic; + Rectf m_Viewport; ScreenManager* m_ScreenManager; @@ -54,7 +61,7 @@ private: OrbitingObject* m_Sun{ nullptr }; OrbitingObject* m_Moon{ nullptr }; - Texture* m_topCover{ nullptr }; + Texture* m_TopCover{ nullptr }; // ImGui Vars diff --git a/Game/Particle/Particle.cpp b/Game/Particle/Particle.cpp index bad2586..82237f1 100644 --- a/Game/Particle/Particle.cpp +++ b/Game/Particle/Particle.cpp @@ -1,10 +1,11 @@ #include "pch.h" #include "Particle.h" -Particle::Particle(const Vector2f& pos, const Vector2f& velocity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_LifeTime { lifetime }, +Particle::Particle(const Vector2f& pos, const Vector2f& velocity,const Vector2f& gravity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_LifeTime { lifetime }, m_Gravity(gravity), m_pTexture { pTexture } { } void Particle::Update(float elapsedSec) { - m_Acceleration = Vector2f { 0.0f, -9.81f * 20}; + // m_Acceleration = Vector2f { 0.0f, -9.81f * 20}; + m_Acceleration = m_Gravity; m_Velocity += m_Acceleration * elapsedSec; m_Position += m_Velocity * elapsedSec; m_LifeTime -= elapsedSec; @@ -12,8 +13,12 @@ void Particle::Update(float elapsedSec) { } void Particle::Draw() const { - m_pTexture->Draw(m_Position); + m_pTexture->Draw(m_Position, {}, m_Flipped); + } bool Particle::IsDead() const { return m_LifeTime <= 0.0f; } +void Particle::SetFlipped(bool flipped) { + m_Flipped = flipped; +} diff --git a/Game/Particle/Particle.h b/Game/Particle/Particle.h index a6237df..8f8a17f 100644 --- a/Game/Particle/Particle.h +++ b/Game/Particle/Particle.h @@ -4,16 +4,22 @@ class Particle { public: Particle() = default; - Particle(const Vector2f& pos, const Vector2f& velocity,float lifetime, Texture* pTexture); + Particle(const Vector2f& pos, const Vector2f& velocity, const Vector2f& gravity, float lifetime, Texture* pTexture); + ~Particle() = default; + void Update(float elapsedSec); void Draw() const; bool IsDead() const; + void SetFlipped(bool flipped); private: Vector2f m_Position; Vector2f m_Velocity; Vector2f m_Acceleration; + Vector2f m_Gravity; + + bool m_Flipped{ false }; float m_LifeTime; Texture* m_pTexture; diff --git a/Game/Player.cpp b/Game/Player.cpp index a1001f9..e22df9d 100644 --- a/Game/Player.cpp +++ b/Game/Player.cpp @@ -18,43 +18,72 @@ Player::Player(const Vector2f& Position, TextureManager* manager) : m_Position(P m_ContactMap[Collision::CollisionDirection::Left] = nullptr; m_ContactMap[Collision::CollisionDirection::Right] = nullptr; - m_walkAnimation = new Animation( + m_WalkAnimation = new Animation( manager->GetTexture("animations/player/player_walk.png"), 8, 0.1f, Rectf { 0, 0, 70, 70 }, true); - m_turnAnimation = new Animation( + m_TurnAnimation = new Animation( manager->GetTexture("animations/player/player_turn.png"), 5, 0.07f, Rectf { 0, 0, 70, 70 }, false); - m_digStartAnimation = new Animation( + m_DigStartAnimation = new Animation( manager->GetTexture("animations/player/player_dig_start.png"), 7, 0.07f, Rectf { 0, 0, 70, 70 }, false); - m_digAnimation = new Animation( + m_DigAnimation = new Animation( manager->GetTexture("animations/player/player_dig.png"), 7, 0.05f, Rectf { 0, 0, 70, 70 }, true); - m_flyStartAnimation = new Animation( + m_FlyStartAnimation = new Animation( manager->GetTexture("animations/player/player_fly_start.png"), 12, 0.05f, Rectf { 0, 0, 70, 70 }, false); - m_flyAnimation = new Animation( + m_FlyAnimation = new Animation( manager->GetTexture("animations/player/player_fly.png"), 5, 0.01f, Rectf { 0, 0, 70, 70 }, true); - m_flyTurnAnimation = new Animation( + m_FlyTurnAnimation = new Animation( manager->GetTexture("animations/player/player_fly_turn.png"), 3, 0.05f, Rectf { 0, 0, 70, 70 }, false); - m_currentAnimation = m_walkAnimation; + m_DieStartAnimation = new Animation( + manager->GetTexture("animations/player/player_die_start.png"), + 11, 0.05f, Rectf { 0, 0, 100, 100 }, false); + + m_DieLoopAnimation = new Animation( + manager->GetTexture("animations/player/player_die_loop.png"), + 4, 0.05f, Rectf { 0, 0, 100, 100 }, true); + + m_CurrentAnimation = m_WalkAnimation; + + + m_IdleSound = new SoundEffect("sound/idle.wav"); + m_FlySound = new SoundEffect("sound/fly.wav"); + m_DigSound = new SoundEffect("sound/drill.wav"); + m_DigSound->SetVolume(64); + m_WalkSound = new SoundEffect("sound/walk.wav"); + m_CurrentSound = m_IdleSound; + } Player::~Player() { - delete m_walkAnimation; - delete m_turnAnimation; - delete m_digAnimation; - delete m_digStartAnimation; + delete m_WalkAnimation; + delete m_TurnAnimation; + delete m_DigAnimation; + delete m_DigStartAnimation; - delete m_flyStartAnimation; - delete m_flyAnimation; - delete m_flyTurnAnimation; + delete m_IdleSound; + delete m_FlySound; + delete m_DigSound; + delete m_WalkSound; + + delete m_FlyStartAnimation; + delete m_FlyAnimation; + delete m_FlyTurnAnimation; + + delete m_DieStartAnimation; + delete m_DieLoopAnimation; + + for (Particle* particle : m_DigParticles) { + delete particle; + } } Collision::CollisionRect Player::GetCollisionRect() const { @@ -81,13 +110,30 @@ void Player::Draw() const { glRotatef(m_Direction == PlayerDirection::Left ? rotateOffset : -rotateOffset, 0, 0, 1); } { - m_currentAnimation->Draw(Vector2f { 0, 0 }, Rectf { 0, 0, frameWidth, frameWidth }); + 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(); } + + for (Particle* particle : m_SmokeParticles) { + utils::SetColor(Colors::WHITE); + particle->Draw(); + } + + +} +void Player::Die() { + m_IsDead = true; + m_CurrentAnimation = m_DieStartAnimation; + m_HasPlayedDeathAnimation = false; } void Player::ProcessImGui() { ImGui::Begin("Collision Info", nullptr, ImGuiWindowFlags_AlwaysAutoResize); @@ -152,6 +198,7 @@ void Player::Dig(Collision::CollisionDirection dir, WorldLevel& level) { //Set the digging location in the center of the destination tile; const WorldTile* tile = m_ContactMap[dir]; m_ToAddPoints = tile->GetTileType()->GetValue(); + m_ToAddTile = tile->GetTileType(); //Add case for bottom because otherwise i clip through the floor m_DigDestination = tile->GetPosition(); if (dir == Collision::Bottom) { @@ -171,7 +218,10 @@ bool Player::CanDig(Collision::CollisionDirection dir, WorldLevel& level) { return false; } GroundTileType type = *tile->GetTileType(); - //TODO: Add a list of non diggable tiles + + if (type == GroundTileTypeManager::GetInstance()->STONE) { + return false; + } if (type == GroundTileTypeManager::GetInstance()->HARD_LEFT || type == GroundTileTypeManager::GetInstance()->HARD_MIDDLE || type == GroundTileTypeManager::GetInstance()-> HARD_RIGHT) { @@ -180,14 +230,32 @@ bool Player::CanDig(Collision::CollisionDirection dir, WorldLevel& level) { return true; } +void Player::ChangeSound(SoundEffect* sound) { + m_PrevSound = m_CurrentSound; + // m_CurrentSound->Stop(); + m_CurrentSound = sound; +} void Player::Update(float elapsedTime, WorldLevel& level) { + + + if (m_IsDead) { + m_CurrentAnimation->Update(elapsedTime); + if (m_CurrentAnimation == m_DieStartAnimation) { + if (m_CurrentAnimation->IsDone()) { + m_CurrentAnimation = m_DieLoopAnimation; + } + } + return; + } + m_BobTimer += elapsedTime; if (m_BobTimer >= m_BobTime) { m_BobUp = !m_BobUp; m_BobTimer = 0.0f; } + std::vector particlesToDelete {}; for (Particle* particle : m_DigParticles) { particle->Update(elapsedTime); @@ -200,17 +268,39 @@ void Player::Update(float elapsedTime, WorldLevel& level) { delete particle; } + 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")); + NewSmokeParticle->SetFlipped(m_Direction == PlayerDirection::Left); + m_SmokeParticles.push_back(NewSmokeParticle); + } + std::vector smokeParticlesToDelete{}; + for (Particle* particle : m_SmokeParticles) { + particle->Update(elapsedTime); + if (particle->IsDead()) { + smokeParticlesToDelete.push_back(particle); + } + } + for (Particle* particle : smokeParticlesToDelete) { + m_SmokeParticles.erase(std::remove(m_SmokeParticles.begin(), m_SmokeParticles.end(), particle), m_SmokeParticles.end()); + delete particle; + } + + //check for keys if (m_State != PlayerState::Digging) { if (utils::isKeyDown(SDL_SCANCODE_W)) { m_State = PlayerState::Flying; // m_Vel.y = m_Speed / 10; m_Acc.y += m_Speed * 10; - if(!m_IsPropellorDeployed) { - m_currentAnimation = m_flyStartAnimation; - m_flyStartAnimation->SetFlipped(m_Direction == PlayerDirection::Right); - } else { - m_currentAnimation = m_flyAnimation; + if (!m_IsPropellorDeployed) { + m_CurrentAnimation = m_FlyStartAnimation; + m_FlyStartAnimation->SetFlipped(m_Direction == PlayerDirection::Right); + } + else { + m_CurrentAnimation = m_FlyAnimation; } m_Grounded = false; } @@ -218,8 +308,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) { if (m_Grounded) { if (this->CanDig(Collision::Bottom, level)) { m_DigDirection = DigDirection::Down; - m_currentAnimation = m_digStartAnimation; - m_currentAnimation->Reset(); + m_CurrentAnimation = m_DigStartAnimation; + m_CurrentAnimation->Reset(); m_IsDiggingPrimed = false; this->Dig(Collision::CollisionDirection::Bottom, level); } @@ -227,15 +317,15 @@ void Player::Update(float elapsedTime, WorldLevel& level) { } if (utils::isKeyDown(SDL_SCANCODE_A)) { if (!m_IsTurning) { - m_walkAnimation->SetFlipped(false); - m_flyAnimation->SetFlipped(false); + m_WalkAnimation->SetFlipped(false); + m_FlyAnimation->SetFlipped(false); } m_Acc.x = -m_Speed; if (m_Direction == PlayerDirection::Right) { m_IsTurning = true; - m_currentAnimation = m_State == PlayerState::Walking ? m_turnAnimation : m_flyTurnAnimation; - m_currentAnimation->SetFlipped(true); - m_currentAnimation->Reset(); + m_CurrentAnimation = m_State == PlayerState::Walking ? m_TurnAnimation : m_FlyTurnAnimation; + m_CurrentAnimation->SetFlipped(true); + m_CurrentAnimation->Reset(); } m_Direction = PlayerDirection::Left; if (m_Grounded && !m_DidJustDigLeft) { @@ -255,16 +345,16 @@ void Player::Update(float elapsedTime, WorldLevel& level) { if (utils::isKeyDown(SDL_SCANCODE_D)) { if (!m_IsTurning) { - m_walkAnimation->SetFlipped(true); - m_flyAnimation->SetFlipped(true); + m_WalkAnimation->SetFlipped(true); + m_FlyAnimation->SetFlipped(true); } m_Acc.x = m_Speed; if (m_Direction == PlayerDirection::Left) { m_IsTurning = true; - m_currentAnimation = m_State == PlayerState::Walking ? m_turnAnimation : m_flyTurnAnimation; - m_currentAnimation->SetFlipped(false); - m_currentAnimation->Reset(); + m_CurrentAnimation = m_State == PlayerState::Walking ? m_TurnAnimation : m_FlyTurnAnimation; + m_CurrentAnimation->SetFlipped(false); + m_CurrentAnimation->Reset(); } m_Direction = PlayerDirection::Right; @@ -296,37 +386,39 @@ void Player::Update(float elapsedTime, WorldLevel& level) { m_Acc = Vector2f { 0, 0 }; - m_currentAnimation->Update(elapsedTime); + m_CurrentAnimation->Update(elapsedTime); - if(m_State == PlayerState::Flying && m_Grounded) { + if (m_State == PlayerState::Flying && m_Grounded) { m_State = PlayerState::Idle; - m_walkAnimation->SetFlipped(m_Direction == PlayerDirection::Right); - m_currentAnimation = m_walkAnimation; + m_WalkAnimation->SetFlipped(m_Direction == PlayerDirection::Right); + m_CurrentAnimation = m_WalkAnimation; m_IsPropellorDeployed = false; - m_flyStartAnimation->Reset(); - - + m_FlyStartAnimation->Reset(); + + } - if (m_currentAnimation->IsDone() && m_IsTurning) { - m_currentAnimation = m_State == PlayerState::Walking ? m_walkAnimation : m_flyAnimation; + if (m_CurrentAnimation->IsDone() && m_IsTurning) { + m_CurrentAnimation = m_State == PlayerState::Walking ? m_WalkAnimation : m_FlyAnimation; m_IsTurning = false; } - if(m_currentAnimation == m_flyStartAnimation) { - if(m_flyStartAnimation->IsDone()) { + if (m_CurrentAnimation == m_FlyStartAnimation) { + if (m_FlyStartAnimation->IsDone()) { m_IsPropellorDeployed = true; - m_currentAnimation = m_flyAnimation; - } else { - m_currentAnimation = m_flyStartAnimation; + m_CurrentAnimation = m_FlyAnimation; + } + else { + m_CurrentAnimation = m_FlyStartAnimation; } } - - if (m_currentAnimation == m_digStartAnimation) { - + if (m_Direction == PlayerDirection::Left) { + m_OutletPos = m_OutLeftPos; + } + else { + m_OutletPos = m_OutRightPos; } - #pragma region Collision m_ContactMap[Collision::CollisionDirection::Top] = nullptr; m_ContactMap[Collision::CollisionDirection::Bottom] = nullptr; @@ -393,7 +485,7 @@ void Player::Update(float elapsedTime, WorldLevel& level) { } } - Collision::CollisionRect rect = world_tile->GetCollisionRect().getCollisionRect(); //TODO: fix this mess + Collision::CollisionRect rect = world_tile->GetCollisionRect().getCollisionRect(); Collision::ResolvePlayerVsRect(*this, elapsedTime, &rect); } #pragma endregion @@ -408,25 +500,35 @@ void Player::Update(float elapsedTime, WorldLevel& level) { } } switch (m_State) { + case PlayerState::Flying: + GameManager::GetInstance().DecreaseFuel(0.06f); + ChangeSound(m_FlySound); + break; case PlayerState::Idle: - m_walkAnimation->SetPlaying(false); + m_WalkAnimation->SetPlaying(false); GameManager::GetInstance().DecreaseFuel(0.02f); + ChangeSound(m_IdleSound); + break; case PlayerState::Walking: - m_walkAnimation->SetPlaying(true); + m_WalkAnimation->SetPlaying(true); GameManager::GetInstance().DecreaseFuel(0.04f); + ChangeSound(m_WalkSound); + break; case PlayerState::Digging: { // m_walkAnimation->SetPlaying(false); + GameManager::GetInstance().DecreaseFuel(0.06f); + ChangeSound(m_DigSound); //Diganimation - m_currentAnimation->Update(elapsedTime); - if (m_currentAnimation->IsDone() && m_State == PlayerState::Digging && !m_IsDiggingPrimed) { + m_CurrentAnimation->Update(elapsedTime); + if (m_CurrentAnimation->IsDone() && m_State == PlayerState::Digging && !m_IsDiggingPrimed) { m_IsDiggingPrimed = true; - m_currentAnimation = m_digAnimation; + m_CurrentAnimation = m_DigAnimation; } if (m_IsDiggingPrimed) { - if (!m_Digging) { //TODO: fix for setting the start position + if (!m_Digging) { m_Digging = true; m_DigStart = m_Position; m_Vel = Vector2f { 0, 0 }; @@ -436,9 +538,8 @@ void Player::Update(float elapsedTime, WorldLevel& level) { //lerp to the destination float progress = utils::map(m_DigProgress, 0.0f, m_DigTime, 0.0f, 1.0f); int particleProgress = (int)utils::map(m_DigProgress, 0.0f, m_DigTime, 0.0f, 100.0f); - std::cout << progress << '\n'; if (particleProgress % 2 == 0) { - m_DigParticles.push_back(new Particle(m_Position + Vector2f{ 20, 0 }, Vector2f { (float)utils::randRange(-200, 200), (float)utils::randRange(-100, -300) }, 5.f, + m_DigParticles.push_back(new Particle(m_Position + Vector2f { 20, 0 }, Vector2f { (float)utils::randRange(-200, 200), (float)utils::randRange(-100, -300) },Vector2f { 0.0f, -9.81f * 20}, 5.f, TextureManager::GetInstance()->GetTexture("particles/dirt_" + std::to_string(utils::randRange(1, 8)) + ".png"))); } m_Position = utils::lerp(m_DigStart, m_DigDestination, progress); @@ -449,11 +550,30 @@ void Player::Update(float elapsedTime, WorldLevel& level) { } if (progress >= 1.0f) { m_State = PlayerState::Idle; - m_currentAnimation = m_walkAnimation; + m_CurrentAnimation = m_WalkAnimation; m_HasDeletedTile = false; m_Digging = false; GameManager::GetInstance().IncreaseScore(m_ToAddPoints); m_ToAddPoints = 0; + + //Add the dug item to the inventory + PlayerInventory* inventory = GameManager::GetInstance().GetInventory(); + InventoryItem item = inventory->GetItemByType(m_ToAddTile); + ItemStack stack = ItemStack { item, 1 }; + inventory->AddItem(stack); + + std::cout << "Added: " << PlayerInventory::GetItemName(item) << std::endl; + + //Print the inventory + std::cout << "-----------------------" << std::endl; + std::cout << "Inventory: " << std::endl; + std::vector items = inventory->GetItems(); + for (ItemStack* i : items) { + std::cout << PlayerInventory::GetItemName(i->m_ItemType) << " Quantity: " << i->m_Quantity << std::endl; + } + + std::cout << "-----------------------" << std::endl; + } } @@ -466,4 +586,15 @@ void Player::Update(float elapsedTime, WorldLevel& level) { if (m_State != PlayerState::Digging) { m_Position = m_Position + m_Vel * elapsedTime; } + + if (m_DidSoundChange) { + m_CurrentSound->Stop(); + m_DidSoundChange = false; + } + if (m_CurrentSound != nullptr) { + if (!m_CurrentSound->IsPlaying()) { + m_CurrentSound->Play(1); + } + } + } diff --git a/Game/Player.h b/Game/Player.h index 5948cfb..93a5210 100644 --- a/Game/Player.h +++ b/Game/Player.h @@ -1,7 +1,9 @@ #pragma once #include "Collision.h" +#include "SoundEffect.h" #include "TextureManager.h" #include "Animations/Animation.h" +#include "GridSystem/WorldTile.h" #include "Particle/Particle.h" class WorldLevel; @@ -66,15 +68,23 @@ public: m_ContactMap[dir] = tile; } + void Die(); + void ProcessImGui(); private: void Dig(Collision::CollisionDirection dir, WorldLevel& level); bool CanDig(Collision::CollisionDirection dir, WorldLevel& level); + + void ChangeSound(SoundEffect* sound); Vector2f m_Position; Vector2f m_Size; + Vector2f m_OutletPos; + Vector2f m_OutLeftPos{ 55, 45}; + Vector2f m_OutRightPos{ 0, 45 }; + Vector2f m_Vel; const float m_Speed{ 400.0f }; @@ -95,33 +105,54 @@ private: WorldTile* m_DigTile{ nullptr }; int m_ToAddPoints{ 0 }; + GroundTileType* m_ToAddTile{ nullptr }; bool m_IsDiggingPrimed{ false }; - std::vector m_DigParticles{}; + std::vector m_DigParticles{}; + std::vector m_SmokeParticles{}; + float m_SmokeTimer{ 0.0f }; + const float m_SmokeTime{ 0.25f }; const float m_DigTime{ 0.5f }; + bool m_IsDead{ false }; + bool m_HasPlayedDeathAnimation{ false }; + bool m_Grounded { false }; bool m_IsTurning{ false }; bool m_DidJustDigRight { false }; bool m_DidJustDigLeft { false }; - Animation* m_currentAnimation{ nullptr }; - Animation* m_walkAnimation; - Animation* m_turnAnimation{ nullptr }; - Animation* m_digStartAnimation{ nullptr }; - Animation* m_digAnimation{ nullptr }; + Animation* m_CurrentAnimation{ nullptr }; + Animation* m_WalkAnimation; + Animation* m_TurnAnimation{ nullptr }; + Animation* m_DigStartAnimation{ nullptr }; + Animation* m_DigAnimation{ nullptr }; - Animation* m_flyStartAnimation{ nullptr }; - Animation* m_flyAnimation{ nullptr }; - Animation* m_flyTurnAnimation{ nullptr }; + Animation* m_FlyStartAnimation{ nullptr }; + Animation* m_FlyAnimation{ nullptr }; + Animation* m_FlyTurnAnimation{ nullptr }; + + Animation* m_DieStartAnimation{ nullptr }; + Animation* m_DieLoopAnimation{ nullptr }; + bool m_IsPropellorDeployed{ false }; PlayerState m_State { PlayerState::Idle }; PlayerDirection m_Direction { PlayerDirection::Left }; DigDirection m_DigDirection { DigDirection::Right }; + SoundEffect* m_IdleSound{ nullptr }; + SoundEffect* m_WalkSound{ nullptr }; + SoundEffect* m_DigSound{ nullptr }; + SoundEffect* m_FlySound{ nullptr }; + + SoundEffect* m_CurrentSound{ nullptr }; + SoundEffect* m_PrevSound{ nullptr }; + + bool m_DidSoundChange{ false }; + //Testing bool m_DrawCollisionRect { true }; }; diff --git a/README.md b/README.md index 0376b83..1fabede 100644 --- a/README.md +++ b/README.md @@ -1,59 +1,59 @@ + - -
-
+ +
+
-

Motherload

+

Motherload

-

- Gather resources and buy upgrades to dig as far as you can. You have to dig ores and sell them to earn cash which you use to buy fuel, digger upgrades, explosives, and other supplies. You can only sell ore and buy items at the surface. If you run out of fuel, your digger explodes and you die (game over). There are more valuable (and heavier) ores as you go deeper into the mine. There are several types of alien artifacts which are of considerable value and appear randomly throughout the mine (below 950 feet). -
- Original game : - General info » - · - Youtube video » -
-
-

-
+

+ Gather resources and buy upgrades to dig as far as you can. You have to dig ores and sell them to earn cash which you use to buy fuel, digger upgrades, explosives, and other supplies. You can only sell ore and buy items at the surface. If you run out of fuel, your digger explodes and you die (game over). There are more valuable (and heavier) ores as you go deeper into the mine. There are several types of alien artifacts which are of considerable value and appear randomly throughout the mine (below 950 feet). +
+ Original game : + General info » + · + Youtube video » +
+
+

+
- -
- Table of Contents -
    -
  1. - About The Project -
  2. -
  3. - My version -
  4. -
  5. - Getting Started -
  6. -
  7. How To Play
  8. -
  9. Class structure
  10. -
  11. Checklist
  12. -
  13. Contact
  14. -
  15. Acknowledgments
  16. -
-
+ +
+ Table of Contents +
    +
  1. + About The Project +
  2. +
  3. + My version +
  4. +
  5. + Getting Started +
  6. +
  7. How To Play
  8. +
  9. Class structure
  10. +
  11. Checklist
  12. +
  13. Contact
  14. +
  15. Acknowledgments
  16. +
+
- + ## About The Project -TODO: add screenshot + +![screenshot.jpg](Assets%2Fscreenshot.jpg) Here's why: -TODO: describe why you chose this game * It's a classic game that I played when I was younger. * It's a game that I can make in a reasonable amount of time. -* -

(back to top)

+

(back to top)

## My version @@ -65,7 +65,7 @@ This section gives a clear and detailed overview of which parts of the original * Resource Collection * Random Generated world * The fuel and sell building - + ### What I will probably make as well: * Dying * Working Lava @@ -74,10 +74,10 @@ This section gives a clear and detailed overview of which parts of the original * Main Menu, Options Screen * Boss fight -

(back to top)

+

(back to top)

- + ## Getting Started Detailed instructions on how to run your game project are in this section. @@ -88,77 +88,93 @@ This is an example of how to list things you need to use the software and how to ### How to run the project -Explain which project (version) must be run. -* any extra steps if required +1. Download the Repo. +2. Open the project in Visual Studio 2022 or Jetbrains Rider. +3. Run the project. -

(back to top)

+

(back to top)

- - - + ## How to play -Use this space to show useful examples of how a game can be played. -Additional screenshots and demos work well in this space. - ### Controls -* W A S D +* W A S D +* Mouse For menues -

(back to top)

+

(back to top)

- -## Class structure + +## Class structure -### Object composition -If you applied object composition (optional); explain where and how. +### Object composition +#### Player +The player has a bunch of objects in the Player class, These are +- Animations +- Particles +- SoundEffects +#### WorldLevel +The world level contains all the objects for the "Main" Game. These are +- Player +- GridManager +- Background Music +- MainScreen (Game UI) +- The Sun and Moon -### Inheritance -Explain where you applied inheritance (mandatory). +### Inheritance +Here are a couple examples on how i used Inheritance throughout the project. -### .. +#### Screens +The Screen class is the base class for all the screens in the game.
+This Class manages all the GuiElements inside of it.
+Also all the subscreens, eg. FuelScreen, SellScreen, even the Main Game ui is a subclass of the Screen type. -

(back to top)

+#### GuiElement +The whole Screen system is based on the GuiElement. This class has a Draw and Update Function.
+This is because the Screen class calls these for each of the subclasses of a GuiElement.
+For Example, the Button class is a subclass of GuiElement.
+The Button class has a Draw and Update function that the Screen class calls. The screen does not know what type of
+update it's calling, it just knows that it's calling the update function of a GuiElement. - +

(back to top)

+ + + ## Checklist - [x] Accept / set up github project - [x] week 01 topics applied - - [ ] const keyword applied proactively (variables, functions,..) - - [ ] static keyword applied proactively (class variables, static functions,..) - - [ ] object composition (optional) - [x] week 02 topics applied - [x] week 03 topics applied -- [ ] week 04 topics applied -- [ ] week 05 topics applied -- [ ] week 06 topics applied -- [ ] week 07 topics applied -- [ ] week 08 topics applied -- [ ] week 09 topics applied (optional) -- [ ] week 10 topics applied (optional) +- [x] week 04 topics applied +- [x] week 05 topics applied +- [x] week 06 topics applied +- [x] week 07 topics applied +- [x] week 08 topics applied +- [x] week 09 topics applied (optional) +- [x] week 10 topics applied (optional) -

(back to top)

+

(back to top)

- + ## Contact Bram Verhulst - bram.verhulst@student.howest.be -Project Link: [Here](https://github.com/HowestDAE/dae16-VerhulstBram) +Project Link: [Here](https://github.com/HowestDAE/dae16-VerhulstBram) +Alternative Project Link (Gitea): [Here](https://git.brammie15.dev/brammie15/dae16-VerhulstBram-GameProject) -

(back to top)

+

(back to top)

- + ## Acknowledgments -Use this space to list resources you find helpful and would like to give credit to. +Use this space to list resources you find helpful and would like to give credit to. * [Example 1: cpp reference on std::vector](https://en.cppreference.com/w/cpp/container/vector) -* .. +* [Dear ImGui for development](https://github.com/ocornut/imgui)

(back to top)

- diff --git a/Resources/animations/player/player_die_loop.png b/Resources/animations/player/player_die_loop.png new file mode 100644 index 0000000..7c6bf71 Binary files /dev/null and b/Resources/animations/player/player_die_loop.png differ diff --git a/Resources/animations/player/player_die_start.png b/Resources/animations/player/player_die_start.png new file mode 100644 index 0000000..78a477f Binary files /dev/null and b/Resources/animations/player/player_die_start.png differ diff --git a/Resources/gui/main/help.png b/Resources/gui/main/help.png new file mode 100644 index 0000000..2cef04f Binary files /dev/null and b/Resources/gui/main/help.png differ diff --git a/Resources/gui/main/inv.png b/Resources/gui/main/inv.png new file mode 100644 index 0000000..9b77238 Binary files /dev/null and b/Resources/gui/main/inv.png differ diff --git a/Resources/gui/main/options.png b/Resources/gui/main/options.png new file mode 100644 index 0000000..1ada26b Binary files /dev/null and b/Resources/gui/main/options.png differ diff --git a/Resources/gui/sell/icons/bronzium.png b/Resources/gui/sell/icons/bronzium.png new file mode 100644 index 0000000..3b376b9 Binary files /dev/null and b/Resources/gui/sell/icons/bronzium.png differ diff --git a/Resources/gui/sell/icons/diamond.png b/Resources/gui/sell/icons/diamond.png new file mode 100644 index 0000000..bd3a6aa Binary files /dev/null and b/Resources/gui/sell/icons/diamond.png differ diff --git a/Resources/gui/sell/icons/einsteinium.png b/Resources/gui/sell/icons/einsteinium.png new file mode 100644 index 0000000..fcc5bf4 Binary files /dev/null and b/Resources/gui/sell/icons/einsteinium.png differ diff --git a/Resources/gui/sell/icons/emerald.png b/Resources/gui/sell/icons/emerald.png new file mode 100644 index 0000000..1a0b6c5 Binary files /dev/null and b/Resources/gui/sell/icons/emerald.png differ diff --git a/Resources/gui/sell/icons/goldium.png b/Resources/gui/sell/icons/goldium.png new file mode 100644 index 0000000..d7ad50f Binary files /dev/null and b/Resources/gui/sell/icons/goldium.png differ diff --git a/Resources/gui/sell/icons/ironium.png b/Resources/gui/sell/icons/ironium.png new file mode 100644 index 0000000..7f9df51 Binary files /dev/null and b/Resources/gui/sell/icons/ironium.png differ diff --git a/Resources/gui/sell/icons/platinium.png b/Resources/gui/sell/icons/platinium.png new file mode 100644 index 0000000..022a56c Binary files /dev/null and b/Resources/gui/sell/icons/platinium.png differ diff --git a/Resources/gui/sell/icons/ruby.png b/Resources/gui/sell/icons/ruby.png new file mode 100644 index 0000000..a6396c7 Binary files /dev/null and b/Resources/gui/sell/icons/ruby.png differ diff --git a/Resources/gui/sell/icons/silverium.png b/Resources/gui/sell/icons/silverium.png new file mode 100644 index 0000000..8aa8eb7 Binary files /dev/null and b/Resources/gui/sell/icons/silverium.png differ diff --git a/Resources/gui/sell/icons/special.png b/Resources/gui/sell/icons/special.png new file mode 100644 index 0000000..a2a6c87 Binary files /dev/null and b/Resources/gui/sell/icons/special.png differ diff --git a/Resources/gui/sell/sellall.png b/Resources/gui/sell/sellall.png new file mode 100644 index 0000000..4dfe816 Binary files /dev/null and b/Resources/gui/sell/sellall.png differ diff --git a/Resources/gui/sell/sellallHighlight.png b/Resources/gui/sell/sellallHighlight.png new file mode 100644 index 0000000..f87d13a Binary files /dev/null and b/Resources/gui/sell/sellallHighlight.png differ diff --git a/Resources/particles/smoke.png b/Resources/particles/smoke.png new file mode 100644 index 0000000..f282f3d Binary files /dev/null and b/Resources/particles/smoke.png differ diff --git a/Resources/sound/bgm.wav b/Resources/sound/bgm.wav new file mode 100644 index 0000000..1deb129 Binary files /dev/null and b/Resources/sound/bgm.wav differ diff --git a/Resources/sound/buy.wav b/Resources/sound/buy.wav new file mode 100644 index 0000000..af135b4 Binary files /dev/null and b/Resources/sound/buy.wav differ diff --git a/Resources/sound/drill.wav b/Resources/sound/drill.wav new file mode 100644 index 0000000..a748e63 Binary files /dev/null and b/Resources/sound/drill.wav differ diff --git a/Resources/sound/fly.wav b/Resources/sound/fly.wav new file mode 100644 index 0000000..8820301 Binary files /dev/null and b/Resources/sound/fly.wav differ diff --git a/Resources/sound/fuel_low.wav b/Resources/sound/fuel_low.wav new file mode 100644 index 0000000..ee9ff31 Binary files /dev/null and b/Resources/sound/fuel_low.wav differ diff --git a/Resources/sound/idle.wav b/Resources/sound/idle.wav new file mode 100644 index 0000000..e1ff51d Binary files /dev/null and b/Resources/sound/idle.wav differ diff --git a/Resources/sound/walk.wav b/Resources/sound/walk.wav new file mode 100644 index 0000000..4e2f6ff Binary files /dev/null and b/Resources/sound/walk.wav differ