From dec2af64080f60661f5bda3d9d702390ea881dcc Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 20 Sep 2021 19:30:22 +0100 Subject: [PATCH] Layers ARE EVENT LISTENERS??? *whaaat* --- Aeon/Aeon.cpp | 19 ++++--------------- Aeon/Aeon.hpp | 23 +++++++++++++++++------ Aeon/Core/Game.hpp | 10 ++++++++++ Aeon/Core/GameLayer.hpp | 21 +++++++++++++++++++++ Game/ExampleGame.cpp | 10 +++++++++- 5 files changed, 61 insertions(+), 22 deletions(-) create mode 100644 Aeon/Core/Game.hpp diff --git a/Aeon/Aeon.cpp b/Aeon/Aeon.cpp index 4975c1b..792a21a 100644 --- a/Aeon/Aeon.cpp +++ b/Aeon/Aeon.cpp @@ -1,6 +1,7 @@ #include "Aeon/Aeon.hpp" #include +#include #include "Aeon/Rendering/ImGui.hpp" @@ -10,13 +11,13 @@ using Aeon::Core::DisplayProperties; using Aeon::Input::Input; -App::App( const DisplayProperties& props ) +App::App( const AppProperties& props, const DisplayProperties& dispProps ) : mDisplay() , mInput() { RegisterAsSink( "ENGINE_DISPLAY_CORE", 0 ); - mDisplay.Create( props ); + mDisplay.Create( dispProps ); } void App::Run() @@ -25,19 +26,7 @@ void App::Run() { mInput.PollInput(); - static float f = 0.0f; - static int counter = 0; - static ImVec4 clearColour = ImVec4( 0.45f, 0.55f, 0.60f, 1.00f ); - - ImGui::Begin( "Hello, world!" ); // Create a window called "Hello, world!" and append into it. - - ImGui::Text( "This is some useful text." ); // Display some text (you can use a format strings too) - ImGui::SliderFloat( "float", &f, 0.0f, 1.0f ); // Edit 1 float using a slider from 0.0f to 1.0f - ImGui::ColorEdit3( "clear color", (float*)&clearColour ); // Edit 3 floats representing a color - - ImGui::End(); - - mDisplay.SetClearColour( clearColour.x, clearColour.y, clearColour.z, clearColour.w ); + std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); mDisplay.EndFrame(); } diff --git a/Aeon/Aeon.hpp b/Aeon/Aeon.hpp index 9b95492..0982df8 100644 --- a/Aeon/Aeon.hpp +++ b/Aeon/Aeon.hpp @@ -2,9 +2,11 @@ #define AEON_AEON_H_ #include +#include #include "Aeon/Core/Display.hpp" #include "Aeon/Core/Events.hpp" +#include "Aeon/Core/GameLayer.hpp" #include "Aeon/Input/Input.hpp" namespace Aeon::Core { @@ -15,25 +17,34 @@ namespace Aeon::Core { class App : public EventListener { public: - App( const DisplayProperties& props ); + App( const AppProperties& props, const DisplayProperties& dispProps ); void Run(); - void PushLayer(); - void PopLayer(); - const Display& GetDisplay(); + void PushLayer( GameLayer layer ); + void PushDebugLayer( GameLayer layer ); + void PopTopLayer( GameLayer layer ); + bool EventRecieved( GenericEvent& e ) override; -private: +public: + void PopLayer(); + void PushTopLayer(); + void PopDebugLayer(); +private: Display mDisplay; Aeon::Input::Input mInput; + // Game layers from z order + std::vector mGameLayers; + std::vector mTopLayers; + std::vector mDebugLayers; + private: - bool mSIGTERM = false; }; diff --git a/Aeon/Core/Game.hpp b/Aeon/Core/Game.hpp new file mode 100644 index 0000000..6cf1976 --- /dev/null +++ b/Aeon/Core/Game.hpp @@ -0,0 +1,10 @@ +#ifndef AEON_CORE_GAME_H_ +#define AEON_CORE_GAME_H_ + +class Game +{ +public: + +}; + +#endif diff --git a/Aeon/Core/GameLayer.hpp b/Aeon/Core/GameLayer.hpp index 139597f..9c9eacf 100644 --- a/Aeon/Core/GameLayer.hpp +++ b/Aeon/Core/GameLayer.hpp @@ -1,2 +1,23 @@ +#ifndef AEON_CORE_GAMELAYER_H_ +#define AEON_CORE_GAMELAYER_H_ +#include "Aeon/Core/Events.hpp" +namespace Aeon::Core +{ + +class GameLayer : public EventListener +{ +public: + virtual void Attach() = 0; + virtual void FrameTick() = 0; + virtual void TimeTick() = 0; + virtual void DetAttach() = 0; + +protected: + +}; + +} + +#endif diff --git a/Game/ExampleGame.cpp b/Game/ExampleGame.cpp index ae2711b..b4a7579 100644 --- a/Game/ExampleGame.cpp +++ b/Game/ExampleGame.cpp @@ -12,8 +12,10 @@ public: // take command line args better (parse them first!) ExampleGame() - : App( { "Game with AEON!" } ) + : App( { "Example" }, { "Game with AEON!" } ) { + GameLevel game; + PushLayer( game ); Run(); } @@ -24,6 +26,12 @@ public: }; +class GameLevel : public Aeon::Core::GameLayer +{ +public: + + +}; int main( int argc, char** argv ) {