WIP HUD
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 55 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
@@ -59,6 +59,7 @@
|
|||||||
#include "GUI/Frame.h"
|
#include "GUI/Frame.h"
|
||||||
#include "GUI/Button.h"
|
#include "GUI/Button.h"
|
||||||
#include "Game/MainMenu.h"
|
#include "Game/MainMenu.h"
|
||||||
|
#include "Game/HUD.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
@@ -77,8 +78,9 @@ public:
|
|||||||
m_Renderer->Initialize();
|
m_Renderer->Initialize();
|
||||||
|
|
||||||
m_FrameStack = new GUI::Frame(m_EventBroker.get());
|
m_FrameStack = new GUI::Frame(m_EventBroker.get());
|
||||||
m_FrameStack->Width = 1920;
|
m_FrameStack->Width = 675;
|
||||||
m_FrameStack->Height = 1080;
|
m_FrameStack->Height = 1080;
|
||||||
|
auto hud = new GUI::HUD(m_FrameStack, "HUD");
|
||||||
auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu");
|
auto menu = new GUI::MainMenu(m_FrameStack, "MainMenu");
|
||||||
|
|
||||||
m_InputManager = std::make_shared<InputManager>(m_Renderer->Window(), m_EventBroker);
|
m_InputManager = std::make_shared<InputManager>(m_Renderer->Window(), m_EventBroker);
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ public:
|
|||||||
// Set up a base frame with an event broker
|
// Set up a base frame with an event broker
|
||||||
Frame(dd::EventBroker* eventBroker)
|
Frame(dd::EventBroker* eventBroker)
|
||||||
: EventBroker(eventBroker)
|
: EventBroker(eventBroker)
|
||||||
|
, BaseFrame(this)
|
||||||
, Rectangle() { }
|
, Rectangle() { }
|
||||||
|
|
||||||
// Create a frame as a child
|
// Create a frame as a child
|
||||||
@@ -77,6 +78,7 @@ public:
|
|||||||
parent->AddChild(this);
|
parent->AddChild(this);
|
||||||
m_Parent = parent;
|
m_Parent = parent;
|
||||||
EventBroker = parent->EventBroker;
|
EventBroker = parent->EventBroker;
|
||||||
|
BaseFrame = parent->BaseFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddChild(Frame* child)
|
void AddChild(Frame* child)
|
||||||
@@ -236,6 +238,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
dd::EventBroker* EventBroker;
|
dd::EventBroker* EventBroker;
|
||||||
|
Frame* BaseFrame = nullptr;
|
||||||
|
|
||||||
std::string m_Name = "UIParent";
|
std::string m_Name = "UIParent";
|
||||||
int m_Layer = 0;
|
int m_Layer = 0;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
@@ -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 <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <intrin.h>
|
|
||||||
|
|
||||||
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<dd::EventBroker> 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<LevelSystem, dd::Events::Contact> m_EContact;
|
|
||||||
dd::EventRelay<LevelSystem, dd::Events::LifeLost> m_ELifeLost;
|
|
||||||
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
|
|
||||||
dd::EventRelay<LevelSystem, dd::Events::MultiBall> m_EMultiBall;
|
|
||||||
dd::EventRelay<LevelSystem, dd::Events::CreatePowerUp> m_ECreatePowerUp;
|
|
||||||
dd::EventRelay<LevelSystem, dd::Events::PowerUpTaken> m_EPowerUpTaken;
|
|
||||||
dd::EventRelay<LevelSystem, dd::Events::StageCleared> 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
|
|
||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "GUI/TextureFrame.h"
|
#include "GUI/TextureFrame.h"
|
||||||
#include "Game/MainMenuMain.h"
|
#include "Game/MainMenuMain.h"
|
||||||
#include "Game/MainMenuOptions.h"
|
#include "Game/MainMenuOptions.h"
|
||||||
|
#include "Core/EKeyUp.h"
|
||||||
|
|
||||||
namespace dd
|
namespace dd
|
||||||
{
|
{
|
||||||
@@ -32,12 +33,24 @@ public:
|
|||||||
m_MainMenuOptions = new GUI::MainMenuOptions(this, "MainMenuOptions");
|
m_MainMenuOptions = new GUI::MainMenuOptions(this, "MainMenuOptions");
|
||||||
m_MainMenuOptions->SetLeft(m_LeftBanner->Right());
|
m_MainMenuOptions->SetLeft(m_LeftBanner->Right());
|
||||||
m_MainMenuOptions->SetTop(m_MainMenuMain->Bottom());
|
m_MainMenuOptions->SetTop(m_MainMenuMain->Bottom());
|
||||||
|
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &MainMenu::OnKeyUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextureFrame* m_LeftBanner;
|
TextureFrame* m_LeftBanner;
|
||||||
MainMenuMain* m_MainMenuMain;
|
MainMenuMain* m_MainMenuMain;
|
||||||
MainMenuOptions* m_MainMenuOptions;
|
MainMenuOptions* m_MainMenuOptions;
|
||||||
|
|
||||||
|
EventRelay<Frame, Events::KeyUp> m_EKeyUp;
|
||||||
|
bool OnKeyUp(const Events::KeyUp& event)
|
||||||
|
{
|
||||||
|
if (event.KeyCode == GLFW_KEY_ESCAPE) {
|
||||||
|
Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public:
|
|||||||
m_OptionsButton->SetTextureHover("Textures/GUI/Menu/MainOptionsHover.png");
|
m_OptionsButton->SetTextureHover("Textures/GUI/Menu/MainOptionsHover.png");
|
||||||
m_OptionsButton->SetTexturePressed("Textures/GUI/Menu/MainOptionsClick.png");
|
m_OptionsButton->SetTexturePressed("Textures/GUI/Menu/MainOptionsClick.png");
|
||||||
m_OptionsButton->SizeToTexture();
|
m_OptionsButton->SizeToTexture();
|
||||||
|
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EButtonRelease, &MainMenuMain::OnButtonRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -48,6 +50,16 @@ private:
|
|||||||
Button* m_SquidoutButton;
|
Button* m_SquidoutButton;
|
||||||
Button* m_TimeAttackButton;
|
Button* m_TimeAttackButton;
|
||||||
Button* m_OptionsButton;
|
Button* m_OptionsButton;
|
||||||
|
|
||||||
|
EventRelay<Frame, Events::ButtonRelease> m_EButtonRelease;
|
||||||
|
virtual bool OnButtonRelease(const Events::ButtonRelease& event)
|
||||||
|
{
|
||||||
|
if (event.Button == m_SquidoutButton) {
|
||||||
|
m_Parent->Hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user