diff --git a/assets/Textures/Core/ErrorTexture.png b/assets/Textures/Core/ErrorTexture.png index a58cfe7..c043940 100755 Binary files a/assets/Textures/Core/ErrorTexture.png and b/assets/Textures/Core/ErrorTexture.png differ diff --git a/assets/Textures/GUI/Loading.png b/assets/Textures/GUI/Loading.png new file mode 100644 index 0000000..870bee9 Binary files /dev/null and b/assets/Textures/GUI/Loading.png differ diff --git a/assets/Textures/GUI/Spacebar.png b/assets/Textures/GUI/Spacebar.png new file mode 100644 index 0000000..5f37a49 Binary files /dev/null and b/assets/Textures/GUI/Spacebar.png differ diff --git a/assets/Textures/GUI/SpacebarSkip.png b/assets/Textures/GUI/SpacebarSkip.png new file mode 100644 index 0000000..b0e96fe Binary files /dev/null and b/assets/Textures/GUI/SpacebarSkip.png differ diff --git a/assets/Textures/Story/Black.png b/assets/Textures/Story/Black.png new file mode 100644 index 0000000..c49ef04 Binary files /dev/null and b/assets/Textures/Story/Black.png differ diff --git a/assets/Textures/Story/Brunn1.png b/assets/Textures/Story/Brunn1.png new file mode 100644 index 0000000..aec0013 Binary files /dev/null and b/assets/Textures/Story/Brunn1.png differ diff --git a/assets/Textures/Story/Brunn2.png b/assets/Textures/Story/Brunn2.png new file mode 100644 index 0000000..031fedc Binary files /dev/null and b/assets/Textures/Story/Brunn2.png differ diff --git a/assets/Textures/Story/Brunn3.png b/assets/Textures/Story/Brunn3.png new file mode 100644 index 0000000..f6a0e7d Binary files /dev/null and b/assets/Textures/Story/Brunn3.png differ diff --git a/assets/Textures/Story/Brunn4.png b/assets/Textures/Story/Brunn4.png new file mode 100644 index 0000000..aec0013 Binary files /dev/null and b/assets/Textures/Story/Brunn4.png differ diff --git a/assets/Textures/Story/Brunn5.png b/assets/Textures/Story/Brunn5.png new file mode 100644 index 0000000..e497b78 Binary files /dev/null and b/assets/Textures/Story/Brunn5.png differ diff --git a/assets/Textures/Story/SubScene1.png b/assets/Textures/Story/SubScene1.png new file mode 100644 index 0000000..ce2d4d1 Binary files /dev/null and b/assets/Textures/Story/SubScene1.png differ diff --git a/assets/Textures/Story/SubScene10.png b/assets/Textures/Story/SubScene10.png new file mode 100644 index 0000000..8aee473 Binary files /dev/null and b/assets/Textures/Story/SubScene10.png differ diff --git a/assets/Textures/Story/SubScene11.png b/assets/Textures/Story/SubScene11.png new file mode 100644 index 0000000..885e850 Binary files /dev/null and b/assets/Textures/Story/SubScene11.png differ diff --git a/assets/Textures/Story/SubScene12.png b/assets/Textures/Story/SubScene12.png new file mode 100644 index 0000000..ada64e4 Binary files /dev/null and b/assets/Textures/Story/SubScene12.png differ diff --git a/assets/Textures/Story/SubScene13.png b/assets/Textures/Story/SubScene13.png new file mode 100644 index 0000000..8248209 Binary files /dev/null and b/assets/Textures/Story/SubScene13.png differ diff --git a/assets/Textures/Story/SubScene14.png b/assets/Textures/Story/SubScene14.png new file mode 100644 index 0000000..ada64e4 Binary files /dev/null and b/assets/Textures/Story/SubScene14.png differ diff --git a/assets/Textures/Story/SubScene15.png b/assets/Textures/Story/SubScene15.png new file mode 100644 index 0000000..96fd295 Binary files /dev/null and b/assets/Textures/Story/SubScene15.png differ diff --git a/assets/Textures/Story/SubScene16.png b/assets/Textures/Story/SubScene16.png new file mode 100644 index 0000000..053c33d Binary files /dev/null and b/assets/Textures/Story/SubScene16.png differ diff --git a/assets/Textures/Story/SubScene17.png b/assets/Textures/Story/SubScene17.png new file mode 100644 index 0000000..433e941 Binary files /dev/null and b/assets/Textures/Story/SubScene17.png differ diff --git a/assets/Textures/Story/SubScene18.png b/assets/Textures/Story/SubScene18.png new file mode 100644 index 0000000..8d638a8 Binary files /dev/null and b/assets/Textures/Story/SubScene18.png differ diff --git a/assets/Textures/Story/SubScene19.png b/assets/Textures/Story/SubScene19.png new file mode 100644 index 0000000..671c390 Binary files /dev/null and b/assets/Textures/Story/SubScene19.png differ diff --git a/assets/Textures/Story/SubScene2.png b/assets/Textures/Story/SubScene2.png new file mode 100644 index 0000000..5ce68a8 Binary files /dev/null and b/assets/Textures/Story/SubScene2.png differ diff --git a/assets/Textures/Story/SubScene3.png b/assets/Textures/Story/SubScene3.png new file mode 100644 index 0000000..ce2d4d1 Binary files /dev/null and b/assets/Textures/Story/SubScene3.png differ diff --git a/assets/Textures/Story/SubScene4.png b/assets/Textures/Story/SubScene4.png new file mode 100644 index 0000000..675bd2d Binary files /dev/null and b/assets/Textures/Story/SubScene4.png differ diff --git a/assets/Textures/Story/SubScene5.png b/assets/Textures/Story/SubScene5.png new file mode 100644 index 0000000..70a609e Binary files /dev/null and b/assets/Textures/Story/SubScene5.png differ diff --git a/assets/Textures/Story/SubScene6.png b/assets/Textures/Story/SubScene6.png new file mode 100644 index 0000000..675bd2d Binary files /dev/null and b/assets/Textures/Story/SubScene6.png differ diff --git a/assets/Textures/Story/SubScene7.png b/assets/Textures/Story/SubScene7.png new file mode 100644 index 0000000..885e850 Binary files /dev/null and b/assets/Textures/Story/SubScene7.png differ diff --git a/assets/Textures/Story/SubScene8.png b/assets/Textures/Story/SubScene8.png new file mode 100644 index 0000000..8aee473 Binary files /dev/null and b/assets/Textures/Story/SubScene8.png differ diff --git a/assets/Textures/Story/SubScene9.png b/assets/Textures/Story/SubScene9.png new file mode 100644 index 0000000..2d47e68 Binary files /dev/null and b/assets/Textures/Story/SubScene9.png differ diff --git a/include/Core/Engine.h b/include/Core/Engine.h index d07be98..742c375 100755 --- a/include/Core/Engine.h +++ b/include/Core/Engine.h @@ -65,8 +65,8 @@ #include "GUI/Frame.h" #include "GUI/Button.h" -#include "Game/MainMenu.h" -#include "Game/HUD.h" +#include "Game/GUI/MainMenu.h" +#include "Game/GUI/HUD.h" namespace dd { diff --git a/include/Core/ResourceManager.h b/include/Core/ResourceManager.h index b16099c..3cebf4a 100644 --- a/include/Core/ResourceManager.h +++ b/include/Core/ResourceManager.h @@ -188,13 +188,13 @@ void ResourceManager::Preload(std::string resourceName) auto resourceType = typeid(T).name(); if (IsResourceLoaded(resourceType, resourceName)) { - LOG_WARNING("Attempted to preload resource \"%s\" multiple times!", resourceName); + LOG_WARNING("Attempted to preload resource \"%s\" multiple times!", resourceName.c_str()); return; } m_Preloading = true; LOG_INFO("Preloading resource \"%s\"", resourceName.c_str()); - CreateResource(resourceName); + CreateResource(resourceName, nullptr); m_Preloading = false; } diff --git a/include/GUI/Frame.h b/include/GUI/Frame.h index f7e302c..8eaedb9 100644 --- a/include/GUI/Frame.h +++ b/include/GUI/Frame.h @@ -44,6 +44,8 @@ public: : m_Name(name) { SetParent(parent); + Width = parent->Width; + Height = parent->Height; EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Frame::OnKeyDown); EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Frame::OnKeyUp); EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Frame::OnCommand); diff --git a/include/GUI/TextureFrame.h b/include/GUI/TextureFrame.h index 12f15c0..5db574c 100644 --- a/include/GUI/TextureFrame.h +++ b/include/GUI/TextureFrame.h @@ -23,18 +23,6 @@ public: if (m_Texture == nullptr) return; - // Main texture - { - FrameJob job; - job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle(); - job.Viewport = Rectangle(Left(), Top(), Width, Height); - job.TextureID = m_Texture->ResourceID; - job.DiffuseTexture = *m_Texture; - job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade); - job.Name = Name(); - rq.GUI.Add(job); - } - // Texture while fading if (m_FadeTexture && m_CurrentFade < 1) { FrameJob job; @@ -46,9 +34,21 @@ public: job.Name = Name(); rq.GUI.Add(job); } + + // Main texture + { + FrameJob job; + job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle(); + job.Viewport = Rectangle(Left(), Top(), Width, Height); + job.TextureID = m_Texture->ResourceID; + job.DiffuseTexture = *m_Texture; + job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade); + job.Name = Name(); + rq.GUI.Add(job); + } } - dd::Texture* Texture() const { return m_Texture; } + std::string Texture() const { return m_TextureName; } void SetTexture(std::string resourceName) { @@ -58,6 +58,7 @@ public: } m_Texture = ResourceManager::Load(resourceName); + m_TextureName = resourceName; if (m_Texture == nullptr) { m_Texture = ResourceManager::Load("Textures/Core/ErrorTexture.png"); } @@ -98,6 +99,7 @@ public: protected: bool m_ScissorEnabled = true; dd::Texture* m_Texture = nullptr; + std::string m_TextureName; dd::Texture* m_FadeTexture = nullptr; glm::vec4 m_Color = glm::vec4(1.f, 1.f, 1.f, 1.f); float m_FadeDuration = 0.f; diff --git a/include/Game/GUI/ELoadingFrameComplete.h b/include/Game/GUI/ELoadingFrameComplete.h new file mode 100644 index 0000000..398c254 --- /dev/null +++ b/include/Game/GUI/ELoadingFrameComplete.h @@ -0,0 +1,23 @@ +#ifndef GAME_GUI_ELOADINGFRAMECOMPLETE_H__ +#define GAME_GUI_ELOADINGFRAMECOMPLETE_H__ + +#include "Core/EventBroker.h" + +namespace dd +{ + +namespace GUI { class LoadingFrame; } + +namespace Events +{ + +struct LoadingFrameComplete : Event +{ + std::string FrameName; + GUI::LoadingFrame* Frame = nullptr; +}; + +} +} + +#endif \ No newline at end of file diff --git a/include/Game/FPSCounter.h b/include/Game/GUI/FPSCounter.h similarity index 100% rename from include/Game/FPSCounter.h rename to include/Game/GUI/FPSCounter.h diff --git a/include/Game/HUD.h b/include/Game/GUI/HUD.h similarity index 95% rename from include/Game/HUD.h rename to include/Game/GUI/HUD.h index 605ef3d..c9dcb8e 100644 --- a/include/Game/HUD.h +++ b/include/Game/GUI/HUD.h @@ -6,7 +6,7 @@ #include "GUI/NumberFrame.h" #include "Core/EKeyUp.h" #include "Game/EScoreEvent.h" -#include "Game/FPSCounter.h" +#include "Game/GUI/FPSCounter.h" #include "Game/EGameOver.h" #include "Game/EClusterClear.h" #include "Game/EKrakenAttack.h" diff --git a/include/Game/GUI/LoadingFrame.h b/include/Game/GUI/LoadingFrame.h new file mode 100644 index 0000000..307ca63 --- /dev/null +++ b/include/Game/GUI/LoadingFrame.h @@ -0,0 +1,73 @@ +#ifndef GAME_GUI_LOADINGFRAME_H__ +#define GAME_GUI_LOADINGFRAME_H__ + +#include "GUI/TextureFrame.h" +#include "GUI/Slider.h" +#include "Core/ResourceManager.h" +#include "Game/GUI/ELoadingFrameComplete.h" + +namespace dd +{ +namespace GUI +{ + +class LoadingFrame : public TextureFrame +{ +public: + LoadingFrame(Frame* parent, std::string name) + : TextureFrame(parent, name) + { + m_Slider = new GUI::Slider(this, "LoadingFrameSlider"); + //m_SFXSlider->X = 0; + m_Slider->Y = 453; + //m_SFXSlider->SetTop(m_TitleSFX->Bottom() + 10); + m_Slider->SetTexture("Textures/GUI/Menu/SliderBackground.png"); + m_Slider->SetTextureReleased("Textures/GUI/Menu/SliderHandle.png"); + m_Slider->AlignVertically(); + m_Slider->SetPercentage(1.f); + m_Slider->X = Width / 2.f - m_Slider->Width / 2.f; + } + + void AddTexturePreload(std::string resourceName) + { + m_Items.push_back(resourceName); + } + + void Preload() + { + m_Preloading = true; + } + + void CancelPreload() + { + m_Preloading = false; + m_CurrentItem = 0; + } + + void Update(double dt) override + { + if (m_Preloading) { + ResourceManager::Preload(m_Items[m_CurrentItem]); + m_Slider->SetPercentage((m_CurrentItem + 1) / (float)m_Items.size()); + m_CurrentItem++; + if (m_CurrentItem >= m_Items.size()) { + m_Preloading = false; + dd::Events::LoadingFrameComplete e; + e.FrameName = Name(); + e.Frame = this; + EventBroker->Publish(e); + } + } + } + +private: + bool m_Preloading = false; + int m_CurrentItem = 0; + std::vector m_Items; + GUI::Slider* m_Slider = nullptr; +}; + +} +} + +#endif \ No newline at end of file diff --git a/include/Game/MainMenu.h b/include/Game/GUI/MainMenu.h similarity index 90% rename from include/Game/MainMenu.h rename to include/Game/GUI/MainMenu.h index fa629d3..0cbc950 100644 --- a/include/Game/MainMenu.h +++ b/include/Game/GUI/MainMenu.h @@ -2,8 +2,8 @@ #define GUI_MAINMENU_H__ #include "GUI/TextureFrame.h" -#include "Game/MainMenuMain.h" -#include "Game/MainMenuOptions.h" +#include "Game/GUI/MainMenuMain.h" +#include "Game/GUI/MainMenuOptions.h" #include "Core/EKeyUp.h" namespace dd diff --git a/include/Game/MainMenuMain.h b/include/Game/GUI/MainMenuMain.h similarity index 90% rename from include/Game/MainMenuMain.h rename to include/Game/GUI/MainMenuMain.h index c74027f..a033c3d 100644 --- a/include/Game/MainMenuMain.h +++ b/include/Game/GUI/MainMenuMain.h @@ -3,8 +3,7 @@ #include "GUI/TextureFrame.h" #include "GUI/Button.h" -#include "Game/EGameStart.h" -#include "Game/HUD.h" +#include "Game/GUI/Story1.h" namespace dd { @@ -57,10 +56,8 @@ private: virtual bool OnButtonRelease(const Events::ButtonRelease& event) { if (event.Button == m_SquidoutButton) { - Events::GameStart e; - EventBroker->Publish(e); m_Parent->Hide(); - auto hud = new GUI::HUD(BaseFrame, "HUD"); + auto story = new GUI::Story1(BaseFrame, "Story1"); } return true; diff --git a/include/Game/MainMenuOptions.h b/include/Game/GUI/MainMenuOptions.h similarity index 100% rename from include/Game/MainMenuOptions.h rename to include/Game/GUI/MainMenuOptions.h diff --git a/include/Game/GUI/Story1.h b/include/Game/GUI/Story1.h new file mode 100644 index 0000000..71fbe97 --- /dev/null +++ b/include/Game/GUI/Story1.h @@ -0,0 +1,247 @@ +#ifndef GAME_GUI_STORY1_H__ +#define GAME_GUI_STORY1_H__ + +#include "Core/ResourceManager.h" +#include "Game/GUI/StoryboardFrame.h" +#include "Game/GUI/ELoadingFrameComplete.h" +#include "Game/GUI/LoadingFrame.h" +#include "Game/EGameStart.h" +#include "Core/EKeyDown.h" +#include "Game/GUI/HUD.h" + +namespace dd +{ +namespace GUI +{ + +class Story1 : public StoryboardFrame +{ +public: + Story1(Frame* parent, std::string name) + : StoryboardFrame(parent, name) + { + EVENT_SUBSCRIBE_MEMBER(m_ELoadingFrameComplete, &Story1::OnLoadingFrameComplete); + EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Story1::OnKeyDown); + + m_LoadingFrame = new GUI::LoadingFrame(this, "Story1LoadingFrame"); + m_LoadingFrame->SetTexture("Textures/GUI/Loading.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn1.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn2.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn3.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn4.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/Brunn5.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene1.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene2.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene3.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene4.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene5.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene6.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene7.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene8.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene9.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene10.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene11.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene12.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene13.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene14.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene15.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene16.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene17.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene18.png"); + m_LoadingFrame->AddTexturePreload("Textures/Story/SubScene19.png"); + m_LoadingFrame->Preload(); + + m_Spacebar = new TextureFrame(this, "ZZZSpacebar"); + m_Spacebar->SetTexture("Textures/GUI/SpacebarSkip.png"); + m_Spacebar->SetRight(Right() - 10); + m_Spacebar->SetBottom(Bottom() - 10); + m_Spacebar->DisableScissor(); + + Transition t; + + /* + Sid in the well scene + */ + + t.Time = t.Time + 0; + t.Duration = 0; + t.Texture = "Textures/Story/Brunn1.png"; + t.Viewport = Rectangle(3108, 11276, 1376, 2203); + AddTransition(t); + + t.Time = t.Time + 2; + t.Duration = 0.5; + t.Texture = "Textures/Story/Brunn2.png"; + AddTransition(t); + + t.Time = t.Time + 3; + t.Duration = 0.5; + t.Texture = "Textures/Story/Brunn3.png"; + AddTransition(t); + + t.Time = t.Time + 3; + t.Duration = 4; + t.Texture = "Textures/Story/Brunn4.png"; + t.Viewport = Rectangle(2232, 0, 2952, 4725); + AddTransition(t); + + t.Time = t.Time + 5; + t.Duration = 0; + t.Texture = "Textures/Story/Brunn5.png"; + AddTransition(t); + + /* + Submarine scene + */ + + t.Time = t.Time + 4; + t.Duration = 2.5; + t.Texture = "Textures/Story/SubScene1.png"; + t.Viewport = Rectangle(976, 0, 1615, 2586); + AddTransition(t); + + // I'm Tom and stuff! + t.Time = t.Time + 1; + t.Duration = 0.5; + t.Texture = "Textures/Story/SubScene2.png"; + AddTransition(t); + + // Pan to the right here + t.Time = t.Time + 3.5; + t.Duration = 2; + t.Texture = "Textures/Story/SubScene3.png"; + t.Viewport = Rectangle(1574, 0, 1615, 2586); + AddTransition(t); + + // ZAP! + t.Time = t.Time + 2.5; + t.Duration = 0.5; + t.Texture = "Textures/Story/SubScene4.png"; + AddTransition(t); + + t.Time = t.Time + 0.5; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene5.png"; + AddTransition(t); + + t.Time = t.Time + 0.1; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene6.png"; + AddTransition(t); + + t.Time = t.Time + 0.5; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene7.png"; + AddTransition(t); + + // BZZT! + t.Time = t.Time + 1; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene8.png"; + AddTransition(t); + + t.Time = t.Time + 0.5; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene9.png"; + AddTransition(t); + + t.Time = t.Time + 0.1; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene10.png"; + AddTransition(t); + + t.Time = t.Time + 0.5; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene11.png"; + AddTransition(t); + + t.Time = t.Time + 1; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene12.png"; + AddTransition(t); + + t.Time = t.Time + 0.5; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene13.png"; + AddTransition(t); + + t.Time = t.Time + 0.2; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene14.png"; + AddTransition(t); + + t.Time = t.Time + 0.5; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene15.png"; + AddTransition(t); + + t.Time = t.Time + 1; + t.Duration = 0.5; + t.Texture = "Textures/Story/SubScene16.png"; + AddTransition(t); + + t.Time = t.Time + 3.5; + t.Duration = 0.5; + t.Texture = "Textures/Story/SubScene17.png"; + AddTransition(t); + + t.Time = t.Time + 3; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene18.png"; + AddTransition(t); + + t.Time = t.Time + 2; + t.Duration = 0; + t.Texture = "Textures/Story/SubScene19.png"; + AddTransition(t); + } + + void Update(double dt) override + { + StoryboardFrame::Update(dt); + + if (m_Spacebar == nullptr) { + } + } + void OnComplete() override + { + m_Spacebar->Show(); + } + +private: + GUI::LoadingFrame* m_LoadingFrame = nullptr; + TextureFrame* m_Spacebar = nullptr; + + EventRelay m_EKeyDown; + bool OnKeyDown(const Events::KeyDown& event) + { + if (Hidden()) { + return false; + } + + if (event.KeyCode == GLFW_KEY_SPACE) { + m_LoadingFrame->CancelPreload(); + Events::GameStart e; + EventBroker->Publish(e); + Hide(); + auto hud = new GUI::HUD(BaseFrame, "HUD"); + } + return true; + } + + EventRelay m_ELoadingFrameComplete; + bool OnLoadingFrameComplete(const Events::LoadingFrameComplete& event) + { + if (event.FrameName == "Story1LoadingFrame") { + event.Frame->Hide(); + m_Spacebar->Hide(); + Play(); + } + return true; + } +}; + +} +} + +#endif \ No newline at end of file diff --git a/include/Game/GUI/StoryboardFrame.h b/include/Game/GUI/StoryboardFrame.h new file mode 100644 index 0000000..d5f2d0a --- /dev/null +++ b/include/Game/GUI/StoryboardFrame.h @@ -0,0 +1,128 @@ +#ifndef GAME_GUI_STORYBOARDFRAME_H__ +#define GAME_GUI_STORYBOARDFRAME_H__ + +#include "GUI/TextureFrame.h" + +namespace dd +{ +namespace GUI +{ + +class StoryboardFrame : public TextureFrame +{ +public: + struct Transition + { + double Time = 0.0; + double Duration = 0.0; + Rectangle Viewport; + std::string Texture; + }; + + StoryboardFrame(Frame* parent, std::string name) + : TextureFrame(parent, name) + { + + m_TextureFrame = new TextureFrame(this, "StoryboardFrameHelper"); + + //m_TextureFrame->DisableScissor(); + } + + void AddTransition(Transition& transition) + { + m_Timeline.push_back(transition); + } + + void Play() + { + m_Playing = true; + } + + void Skip() + { + m_Playing = false; + OnComplete(); + } + + void Update(double dt) + { + if (Hidden()) { + return; + } + + if (m_Playing) { + m_Time += dt; + + if (m_NextIndex < m_Timeline.size()) { + if (m_Time >= m_Timeline.at(m_NextIndex).Time) { + m_CurrentIndex = m_NextIndex; + Transition& t = m_Timeline.at(m_CurrentIndex); + + m_TextureFrame->FadeToTexture(t.Texture, t.Duration); + //m_TextureFrame->SetTexture(t.Texture); + m_TextureFrame->SizeToTexture(); + + if (m_StartRect == Rectangle()) { + m_StartRect = Rectangle(0, 0, m_TextureFrame->Width, m_TextureFrame->Height); + } + else { + m_StartRect = m_TargetRect; + } + + double wScaleParent = Width / (double)m_TextureFrame->Width; + double wScale = m_TextureFrame->Width / (double)t.Viewport.Width; + LOG_DEBUG("wScale: %f", wScale); + double hScaleParent = Height / (double)m_TextureFrame->Height; + double hScale = m_TextureFrame->Height / (double)t.Viewport.Height; + LOG_DEBUG("hScale: %f", hScale); + m_TargetRect.X = -t.Viewport.X * wScale * wScaleParent; + m_TargetRect.Y = -t.Viewport.Y * hScale * hScaleParent; + m_TargetRect.Width = m_TextureFrame->Width * wScale * wScaleParent; + m_TargetRect.Height = m_TextureFrame->Height * hScale * hScaleParent; + + m_NextIndex++; + } + } else { + OnComplete(); + } + } + + Transition& t = m_Timeline.at(m_CurrentIndex); + double progress = glm::min((m_Time - t.Time)/t.Duration, 1.0); + m_TextureFrame->X = (int)easeSine(progress, m_StartRect.X, (m_TargetRect.X - m_StartRect.X), 1.0); + m_TextureFrame->Y = (int)easeSine(progress, m_StartRect.Y, (m_TargetRect.Y - m_StartRect.Y), 1.0); + m_TextureFrame->Width = (int)easeSine(progress, m_StartRect.Width, (m_TargetRect.Width - m_StartRect.Width), 1.0); + m_TextureFrame->Height = (int)easeSine(progress, m_StartRect.Height, (m_TargetRect.Height - m_StartRect.Height), 1.0); + } + + virtual void OnComplete() { } + +protected: + TextureFrame* m_TextureFrame = nullptr; + +private: + bool m_Playing = false; + double m_Time = 0; + int m_CurrentIndex = 0; + int m_NextIndex = 0; + std::vector m_Timeline; + Rectangle m_StartRect; + Rectangle m_TargetRect; + + double easeSine(double t, double b, double c, double d) + { + return -c / 2 * (glm::cos(glm::pi()*t / d) - 1) + b; + } + + float easeExpo(float t,float b , float c, float d) { + if (t == 0) return b; + if (t == d) return b + c; + if ((t /= d / 2) < 1) return c / 2 * pow(2, 10 * (t - 1)) + b; + return c / 2 * (-pow(2, -10 * --t) + 2) + b; + } +}; + +} +} + +#endif diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index b4fe3b4..2552cb9 100755 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -70,6 +70,11 @@ file(GLOB SOURCE_FILES_Game "Game/*.cpp" ) source_group(Game FILES ${SOURCE_FILES_Game}) +file(GLOB SOURCE_FILES_Game_GUI + "${INCLUDE_PATH}/Game/GUI/*.h" + "Game/GUI/*.cpp" +) +source_group(Game\\GUI FILES ${SOURCE_FILES_Game_GUI}) file(GLOB SOURCE_FILES_Sound "${INCLUDE_PATH}/Sound/*.h" @@ -91,8 +96,10 @@ set(SOURCE_FILES ${SOURCE_FILES_Transform} ${SOURCE_FILES_Physics} ${SOURCE_FILES_Game} + ${SOURCE_FILES_Game_GUI} ${SOURCE_FILES_Sound} - ${SOURCE_FILES_GUI}) + ${SOURCE_FILES_GUI} +) if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") diff --git a/src/game/Core/Renderer.cpp b/src/game/Core/Renderer.cpp index 8ae69cd..674fc96 100755 --- a/src/game/Core/Renderer.cpp +++ b/src/game/Core/Renderer.cpp @@ -665,6 +665,7 @@ void dd::Renderer::DrawGUI(dd::RenderQueue& rq) glUniformMatrix4fv(glGetUniformLocation(*m_SpScreen, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP)); glUniformMatrix4fv(glGetUniformLocation(*m_SpScreen, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix)); glUniformMatrix4fv(glGetUniformLocation(*m_SpScreen, "V"), 1, GL_FALSE, glm::value_ptr(viewMatrix)); + glUniform4fv(glGetUniformLocation(*m_SpScreen, "Color"), 1, glm::value_ptr(frameJob->Color)); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, frameJob->DiffuseTexture); diff --git a/src/game/Core/Shaders/Screen/Fragment.glsl b/src/game/Core/Shaders/Screen/Fragment.glsl index 5f9786e..f656e91 100644 --- a/src/game/Core/Shaders/Screen/Fragment.glsl +++ b/src/game/Core/Shaders/Screen/Fragment.glsl @@ -20,11 +20,13 @@ layout (binding=0) uniform sampler2D DiffuseTexture; +uniform vec4 Color; + in vec2 TextureCoord; out vec4 FragmentColor; void main() { - FragmentColor = texture(DiffuseTexture, TextureCoord); + FragmentColor = texture(DiffuseTexture, TextureCoord) * Color; } \ No newline at end of file diff --git a/src/game/Game/LevelSystem.cpp b/src/game/Game/LevelSystem.cpp index c663343..6a6f1fd 100755 --- a/src/game/Game/LevelSystem.cpp +++ b/src/game/Game/LevelSystem.cpp @@ -212,7 +212,7 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe model->ModelFile = "Models/Brick/StickyBrick.obj"; } else if (typeInt == InkBlasterBrick) { cBrick->Type = InkBlasterBrick; - model->Color = glm::vec4(0.1f, 0.1f, 0.1f, .0f); + model->Color = glm::vec4(0.1f, 0.1f, 0.1f, 1.0f); } else if (typeInt == KrakenAttackBrick) { cBrick->Type = KrakenAttackBrick; model->Color = glm::vec4(0.f, 0.5f, 1.0f, .0f); @@ -285,6 +285,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event) auto transformComponentBrick = m_World->GetComponent(entityBrick); auto transformComponentShot = m_World->GetComponent(entityShot); + auto brickModel = m_World->GetComponent(entityBrick); Events::SetImpulse e; e.Entity = entityBrick; @@ -303,6 +304,22 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event) EventBroker->Publish(es); m_World->RemoveEntity(entityShot); + + Events::CreateParticleSequence ep; + ep.parent = entityBrick; + ep.EmitterLifeTime = 1.f; + ep.ParticleLifeTime = 1.5f; + ep.ParticlesPerTick = 1; + ep.SpawnRate = 0.2; + ep.EmittingAngle = glm::half_pi(); + ep.Spread = 1.5f; + ep.Position = transformComponentBrick->Position; + ep.Radius = 0.05; + ep.SpriteFile = "Textures/Particles/FadeBall.png"; + ep.Color = brickModel->Color + glm::vec4(0.3f); + ep.Speed = 50; + EventBroker->Publish(ep); + return true; } @@ -354,7 +371,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event) ep.Position = transformComponentBrick->Position; ep.Radius = 0.05; ep.SpriteFile = "Textures/Particles/FadeBall.png"; - ep.Color = brickModel->Color + glm::vec4(1); + ep.Color = brickModel->Color + glm::vec4(0.3f); ep.Speed = 50; EventBroker->Publish(ep); @@ -479,6 +496,23 @@ void dd::Systems::LevelSystem::GetNextLevel() glm::vec4 c = glm::vec4(0, 1, 1, 0); glm::vec4 m = glm::vec4(1, 0, 1, 0); glm::vec4 d = glm::vec4(0, 0, 0, 0); + + //glm::vec4 p4 = glm::vec4(asd.f / 255.f, asd.f / 255.f, sad.f / 255.f, 1.f); + glm::vec4 br = glm::vec4(143.f / 255.f, 98.f / 255.f, 0.f / 255.f, 1.f); + + glm::vec4 lb1 = glm::vec4(115.f / 255.f, 232.f / 255.f, 236.f / 255.f, 1.f); + glm::vec4 lb2 = glm::vec4(107.f / 255.f, 214.f / 255.f, 218.f / 255.f, 1.f); + glm::vec4 lb3 = glm::vec4(91.f / 255.f, 183.f / 255.f, 186.f / 255.f, 1.f); + glm::vec4 lb4 = glm::vec4(70.f / 255.f, 153.f / 255.f, 156.f / 255.f, 1.f); + + glm::vec4 p1 = glm::vec4(255.f / 255.f, 184.f / 255.f, 254.f / 255.f, 1.f); + glm::vec4 p2 = glm::vec4(255.f / 255.f, 81.f / 255.f, 253.f / 255.f, 1.f); + glm::vec4 p3 = glm::vec4(189.f / 255.f, 0.f / 255.f, 187.f / 255.f, 1.f); + glm::vec4 p4 = glm::vec4(125.f / 255.f, 0.f / 255.f, 147.f / 255.f, 1.f); + + + + if (m_CurrentCluster == 0) { if (m_CurrentLevel == 1) { level = @@ -559,78 +593,79 @@ void dd::Systems::LevelSystem::GetNextLevel() } else if (m_CurrentCluster == 1) { if (m_CurrentLevel == 1) { level = - {1, 1, 0, 1, 0, 1, 1, + {0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 2, 1, 2, 1, - 1, 1, 0, 1, 0, 1, 1, - 4, 0, 0, 3, 0, 0, 5}; - color = - {w, w, w, w, w, w, w, - r, g, b, y, c, m, d, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w}; - } else if (m_CurrentLevel == 2) { - level = - {1, 0, 0, 0, 0, 0, 1, - 0, 1, 0, 0, 0, 1, 0, - 0, 0, 2, 2, 2, 0, 0, - 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, + 1, 0, 1, 2, 1, 0, 1, + 0, 1, 0, 1, 0, 1, 0, + 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0}; color = {w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, + lb4, lb4, lb4, lb4, lb4, lb4, lb4, + lb3, lb3, lb3, lb3, lb3, lb3, lb3, + lb2, lb2, lb2, lb2, lb2, lb2, lb2, + lb1, lb1, lb1, lb1, lb1, lb1, lb1, w, w, w, w, w, w, w}; + } else if (m_CurrentLevel == 2) { + level = + {0, 0, 1, 0, 1, 0, 0, + 0, 1, 0, 1, 0, 1, 0, + 0, 0, 1, 1, 1, 0, 0, + 0, 0, 0, 3, 0, 0, 0, + 1, 1, 1, 0, 1, 1, 1, + 1, 0, 0, 0, 0, 0, 1}; + color = + {w, w, r, w, r, w, w, + w, w, w, r, w, w, w, + w, w, r, w, r, w, w, + w, w, w, w, w, w, w, + w, r, w, w, w, r, w, + r, w, w, w, w, w, r}; } else if (m_CurrentLevel == 3) { level = - {2, 0, 0, 0, 0, 0, 2, - 0, 1, 0, 0, 0, 1, 0, - 1, 2, 1, 1, 1, 2, 1, - 1, 0, 1, 1, 1, 0, 1, - 1, 0, 1, 1, 1, 0, 1, - 1, 0, 1, 1, 1, 0, 1}; + {0, 0, 0, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0, + 0, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 4, 1, 1, 1, + 0, 0, 0, 1, 0, 0, 0, + 0, 0, 1, 1, 1, 0, 0}; color = - {w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w}; + {g, g, g, g, g, g, g, + g, g, g, g, g, g, g, + g, g, g, g, g, g, g, + g, g, g, w, g, g, g, + w, w, w, br, w, w, w, + w, w, br, br, br, w, w}; + } else if (m_CurrentLevel == 4) { level = - {1, 2, 1, 1, 1, 2, 1, - 1, 0, 1, 1, 1, 0, 1, - 1, 2, 1, 1, 1, 2, 1, - 1, 0, 1, 1, 1, 0, 1, - 1, 0, 0, 0, 0, 0, 1, - 0, 1, 1, 0, 1, 1, 0}; + {0, 0, 1, 0, 1, 0, 0, + 0, 1, 1, 1, 1, 1, 0, + 1, 1, 1, 1, 1, 1, 1, + 0, 1, 1, 1, 1, 1, 0, + 0, 0, 1, 5, 1, 0, 0, + 0, 0, 0, 1, 0, 0, 0}; color = - {w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w}; + {w, w, p1, w, p1, w, w, + w, p2, p3, p2, p3, p2, w, + p1, p2, p3, p4, p3, p2, p1, + w, p1, p2, p3, p2, p1, w, + w, w, p1, w, p1, w, w, + w, w, w, p1, w, w, w}; } else if (m_CurrentLevel == 5) { level = - {1, 0, 1, 0, 1, 0, 1, + {0, 1, 0, 0, 0, 1, 0, + 1, 4, 1, 1, 1, 3, 1, 0, 1, 0, 1, 0, 1, 0, - 2, 0, 1, 0, 1, 0, 2, - 0, 1, 0, 2, 0, 1, 0, - 1, 0, 1, 0, 1, 0, 1, - 0, 1, 0, 1, 0, 1, 0}; + 0, 1, 0, 1, 0, 1, 0, + 1, 5, 1, 1, 1, 2, 1, + 0, 1, 0, 0, 0, 1, 0}; color = - {w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w, - w, w, w, w, w, w, w}; + {w, p3, w, w, w, r, w, + p2, w, p1, g, w, w, w, + w, p4, w, g, w, r, w, + w, br, w, g, w, lb1, w, + y, w, y, g, b, w, b, + w, br, w, w, w, lb1, w}; } } else if (m_CurrentCluster == 3) { diff --git a/src/game/Game/PadSystem.cpp b/src/game/Game/PadSystem.cpp index 84d55e8..9067ddb 100755 --- a/src/game/Game/PadSystem.cpp +++ b/src/game/Game/PadSystem.cpp @@ -94,7 +94,7 @@ void dd::Systems::PadSystem::Update(double dt) Events::KrakenAttack e; e.ChargeUpdate = m_KrakenCharge; EventBroker->Publish(e); - std::cout << "Charge: " << m_KrakenCharge << std::endl; + //std::cout << "Charge: " << m_KrakenCharge << std::endl; return; } diff --git a/src/game/Physics/PhysicsSystem.cpp b/src/game/Physics/PhysicsSystem.cpp index a0eee94..94778d1 100755 --- a/src/game/Physics/PhysicsSystem.cpp +++ b/src/game/Physics/PhysicsSystem.cpp @@ -713,7 +713,7 @@ bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event) e.Position = glm::vec3(event.IntersectionPoint.x, event.IntersectionPoint.y, -10); e.Radius = 0.2f; e.SpriteFile = "Textures/Particles/Cloud_Particle.png"; - e.Color = model->Color + glm::vec4(1); + e.Color = model->Color + glm::vec4(0.5f); e.Speed = 100; EventBroker->Publish(e); return true;