diff --git a/assets/Textures/GUI/HUD/LevelIndicatorBG.png b/assets/Textures/GUI/HUD/LevelIndicatorBG.png new file mode 100644 index 0000000..46cc1b3 Binary files /dev/null and b/assets/Textures/GUI/HUD/LevelIndicatorBG.png differ diff --git a/assets/Textures/GUI/HUD/ScoreIndicatorBG.png b/assets/Textures/GUI/HUD/ScoreIndicatorBG.png new file mode 100644 index 0000000..db97909 Binary files /dev/null and b/assets/Textures/GUI/HUD/ScoreIndicatorBG.png differ diff --git a/include/Core/Engine.h b/include/Core/Engine.h index 3b74562..5886f2f 100644 --- a/include/Core/Engine.h +++ b/include/Core/Engine.h @@ -59,6 +59,7 @@ #include "GUI/Frame.h" #include "GUI/Button.h" #include "Game/MainMenu.h" +#include "Game/HUD.h" namespace dd { @@ -77,8 +78,9 @@ public: m_Renderer->Initialize(); m_FrameStack = new GUI::Frame(m_EventBroker.get()); - m_FrameStack->Width = 1920; + m_FrameStack->Width = 675; m_FrameStack->Height = 1080; + auto hud = new GUI::HUD(m_FrameStack, "HUD"); auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu"); m_InputManager = std::make_shared(m_Renderer->Window(), m_EventBroker); diff --git a/include/GUI/Frame.h b/include/GUI/Frame.h index 8594ead..f7e302c 100644 --- a/include/GUI/Frame.h +++ b/include/GUI/Frame.h @@ -36,6 +36,7 @@ public: // Set up a base frame with an event broker Frame(dd::EventBroker* eventBroker) : EventBroker(eventBroker) + , BaseFrame(this) , Rectangle() { } // Create a frame as a child @@ -77,6 +78,7 @@ public: parent->AddChild(this); m_Parent = parent; EventBroker = parent->EventBroker; + BaseFrame = parent->BaseFrame; } void AddChild(Frame* child) @@ -236,6 +238,7 @@ public: protected: dd::EventBroker* EventBroker; + Frame* BaseFrame = nullptr; std::string m_Name = "UIParent"; int m_Layer = 0; diff --git a/include/Game/HUD.h b/include/Game/HUD.h new file mode 100644 index 0000000..e660a9e --- /dev/null +++ b/include/Game/HUD.h @@ -0,0 +1,37 @@ +#ifndef GUI_HUD_H__ +#define GUI_HUD_H__ + +#include "GUI/Frame.h" +#include "GUI/TextureFrame.h" + +namespace dd +{ +namespace GUI +{ + +class HUD : public Frame +{ +public: + HUD(Frame* parent, std::string name) + : Frame(parent, name) + { + Width = parent->Width; + Height = parent->Height; + + m_LevelIndicator = new GUI::TextureFrame(this, "HUDLevelIndicator"); + m_LevelIndicator->SetTexture("Textures/GUI/HUD/LevelIndicatorBG.png"); + + m_ScoreIndicator = new GUI::TextureFrame(this, "HUDScoreIndicator"); + m_ScoreIndicator->SetTexture("Textures/GUI/HUD/ScoreIndicatorBG.png"); + m_ScoreIndicator->SetRight(Right()); + } + +private: + TextureFrame* m_LevelIndicator = nullptr; + TextureFrame* m_ScoreIndicator = nullptr; +}; + +} +} +#endif + diff --git a/include/Game/LevelSystem.h.orig b/include/Game/LevelSystem.h.orig deleted file mode 100755 index 5e56ad3..0000000 --- a/include/Game/LevelSystem.h.orig +++ /dev/null @@ -1,149 +0,0 @@ -// -// Created by Adniklastrator on 2015-09-09. -// - -#ifndef DAYDREAM_LEVELSYSTEM_H -#define DAYDREAM_LEVELSYSTEM_H - -#include "Core/System.h" -#include "Core/CTransform.h" -#include "Core/EventBroker.h" -#include "Core/World.h" -#include "Rendering/CSprite.h" -#include "Rendering/CModel.h" -#include "Game/CBrick.h" -#include "Game/CBall.h" -#include "Game/CLife.h" -#include "Game/CPowerUp.h" -#include "Game/EStageCleared.h" -#include "Game/ELifeLost.h" -#include "Game/EResetBall.h" -#include "Game/EScoreEvent.h" -<<<<<<< HEAD -#include "Physics/CRectangleShape.h" -======= -#include "Game/EMultiBall.h" -#include "Game/EGameOver.h" -#include "Game/ECreatePowerUp.h" -#include "Game/EPowerUpTaken.h" -#include "Game/Bricks/CPowerUpBrick.h" -#include "Physics/CBoxShape.h" ->>>>>>> 72413dc0a93bd3a2f6ab9fa7e19bbc3b846232db -#include "Physics/CPhysics.h" -#include "Physics/CCircleShape.h" -#include "Physics/ESetImpulse.h" -#include "Physics/EContact.h" -#include "Sound/CCollisionSound.h" -#include "Game/PadSystem.h" -#include -#include -#include - -namespace dd -{ - -namespace Systems -{ - - // Me trying things out. -class Level -{ -public: - int levelRows; - int levelLines; - int levelSpaceBetweenBricks; - int levelSpaceToEdge; - int bricks[]; -}; - -class LevelSystem : public System -{ -public: - LevelSystem(World* world, std::shared_ptr eventBroker) - : System(world, eventBroker) - { } - - void Initialize() override; - - void CreateBasicLevel(int, int, glm::vec2, float); - void CreateLife(int); - void SaveLevel(int, int, glm::vec2, int); // Shouldn't be here, but I'm experimenting. - void LoadLevel(char[20]); - void CreateBrick(int, int, glm::vec2, float, int); - void ProcessCollision(); - - void OnEntityRemoved(EntityID entity); - - void EndLevel(); - - void Update(double dt) override; - void UpdateEntity(double dt, EntityID entity, EntityID parent) override; - - bool Restarting() const { return m_Restarting; } - void SetRestarting(const bool& restarting) { m_Restarting = restarting; } - bool Initialized() const { return m_Initialized; } - void SetInitialized(const bool& initialized) { m_Initialized = initialized; } - int& Lives() { return m_Lives; } - void SetLives(const int& lives) { m_Lives = lives; } - int& PastLives() { return m_PastLives; } - void SetPastLives(const int& pastLives) { m_PastLives = pastLives; } - int& MultiBalls() { return m_MultiBalls; } - void SetMultiBalls(const int& multiBalls) { m_MultiBalls = multiBalls; } - int& PowerUps() { return m_PowerUps; } - void SetPowerUps(const int& powerUps) { m_PowerUps = powerUps; } - int& Score() { return m_Score; } - void SetScore(const int& score) { m_Score = score; } - int& NumberOfBricks() { return m_NumberOfBricks; } - void SetNumberOfBricks(const int& numberOfBricks) { m_NumberOfBricks = numberOfBricks; } - int& Rows() { return m_Rows; } - void SetRows(const int& rows) { m_Rows = rows; } - int& Lines() { return m_Lines; } - void SetLines(const int& lines) { m_Lines = lines; } - float& SpaceToEdge() { return m_SpaceToEdge; } - void SetSpaceToEdge(const float& spaceToEdge) { m_SpaceToEdge = spaceToEdge; } - - glm::vec2& SpaceBetweenBricks() { return m_SpaceBetweenBricks; } - void SetSpaceBetweenBricks(const glm::vec2& spaceBetweenBricks) { m_SpaceBetweenBricks = spaceBetweenBricks; } - float& EdgeX() { return m_EdgeX; } - void SetEdgeX(const float& edgeX) { m_EdgeX = edgeX; } - float& EdgeY() { return m_EdgeY; } - void SetEdgeY(const float& edgeY) { m_EdgeY = edgeY; } - -private: - bool m_Restarting = false; - bool m_Initialized = false; - int m_Lives = 3; - int m_PastLives = 3; - int m_MultiBalls = 0; - int m_PowerUps = 0; - int m_Score = 0; - int m_NumberOfBricks; - int m_Rows = 6; - int m_Lines = 7; - float m_SpaceToEdge = 0.25f; - glm::vec2 m_SpaceBetweenBricks = glm::vec2(1, 0.4); - float m_EdgeX = 3.2f; - float m_EdgeY = 5.2f; - - dd::EventRelay m_EContact; - dd::EventRelay m_ELifeLost; - dd::EventRelay m_EScoreEvent; - dd::EventRelay m_EMultiBall; - dd::EventRelay m_ECreatePowerUp; - dd::EventRelay m_EPowerUpTaken; - dd::EventRelay m_EStageCleared; - - bool OnContact(const dd::Events::Contact &event); - bool OnLifeLost(const dd::Events::LifeLost &event); - bool OnScoreEvent(const dd::Events::ScoreEvent &event); - bool OnMultiBall(const dd::Events::MultiBall &event); - bool OnCreatePowerUp(const dd::Events::CreatePowerUp &event); - bool OnPowerUpTaken(const dd::Events::PowerUpTaken &event); - bool OnStageCleared(const dd::Events::StageCleared &event); -}; - -} - -} - -#endif //DAYDREAM_LEVELSYSTEM_H diff --git a/include/Game/MainMenu.h b/include/Game/MainMenu.h index f2c6a02..a9afe4c 100644 --- a/include/Game/MainMenu.h +++ b/include/Game/MainMenu.h @@ -4,6 +4,7 @@ #include "GUI/TextureFrame.h" #include "Game/MainMenuMain.h" #include "Game/MainMenuOptions.h" +#include "Core/EKeyUp.h" namespace dd { @@ -32,12 +33,24 @@ public: m_MainMenuOptions = new GUI::MainMenuOptions(this, "MainMenuOptions"); m_MainMenuOptions->SetLeft(m_LeftBanner->Right()); m_MainMenuOptions->SetTop(m_MainMenuMain->Bottom()); + + EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &MainMenu::OnKeyUp); } private: TextureFrame* m_LeftBanner; MainMenuMain* m_MainMenuMain; MainMenuOptions* m_MainMenuOptions; + + EventRelay m_EKeyUp; + bool OnKeyUp(const Events::KeyUp& event) + { + if (event.KeyCode == GLFW_KEY_ESCAPE) { + Show(); + } + + return true; + } }; } diff --git a/include/Game/MainMenuMain.h b/include/Game/MainMenuMain.h index 7181c6e..fb0f2fe 100644 --- a/include/Game/MainMenuMain.h +++ b/include/Game/MainMenuMain.h @@ -41,6 +41,8 @@ public: m_OptionsButton->SetTextureHover("Textures/GUI/Menu/MainOptionsHover.png"); m_OptionsButton->SetTexturePressed("Textures/GUI/Menu/MainOptionsClick.png"); m_OptionsButton->SizeToTexture(); + + EVENT_SUBSCRIBE_MEMBER(m_EButtonRelease, &MainMenuMain::OnButtonRelease); } private: @@ -48,6 +50,16 @@ private: Button* m_SquidoutButton; Button* m_TimeAttackButton; Button* m_OptionsButton; + + EventRelay m_EButtonRelease; + virtual bool OnButtonRelease(const Events::ButtonRelease& event) + { + if (event.Button == m_SquidoutButton) { + m_Parent->Hide(); + } + + return true; + } }; }