Layers ARE EVENT LISTENERS??? *whaaat*

This commit is contained in:
Ben
2021-09-20 19:30:22 +01:00
parent 8b74ad752c
commit dec2af6408
5 changed files with 61 additions and 22 deletions

View File

@@ -1,6 +1,7 @@
#include "Aeon/Aeon.hpp" #include "Aeon/Aeon.hpp"
#include <iostream> #include <iostream>
#include <thread>
#include "Aeon/Rendering/ImGui.hpp" #include "Aeon/Rendering/ImGui.hpp"
@@ -10,13 +11,13 @@ using Aeon::Core::DisplayProperties;
using Aeon::Input::Input; using Aeon::Input::Input;
App::App( const DisplayProperties& props ) App::App( const AppProperties& props, const DisplayProperties& dispProps )
: mDisplay() : mDisplay()
, mInput() , mInput()
{ {
RegisterAsSink( "ENGINE_DISPLAY_CORE", 0 ); RegisterAsSink( "ENGINE_DISPLAY_CORE", 0 );
mDisplay.Create( props ); mDisplay.Create( dispProps );
} }
void App::Run() void App::Run()
@@ -25,19 +26,7 @@ void App::Run()
{ {
mInput.PollInput(); mInput.PollInput();
static float f = 0.0f; std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
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 );
mDisplay.EndFrame(); mDisplay.EndFrame();
} }

View File

@@ -2,9 +2,11 @@
#define AEON_AEON_H_ #define AEON_AEON_H_
#include <string> #include <string>
#include <vector>
#include "Aeon/Core/Display.hpp" #include "Aeon/Core/Display.hpp"
#include "Aeon/Core/Events.hpp" #include "Aeon/Core/Events.hpp"
#include "Aeon/Core/GameLayer.hpp"
#include "Aeon/Input/Input.hpp" #include "Aeon/Input/Input.hpp"
namespace Aeon::Core { namespace Aeon::Core {
@@ -15,25 +17,34 @@ namespace Aeon::Core {
class App : public EventListener class App : public EventListener
{ {
public: public:
App( const DisplayProperties& props ); App( const AppProperties& props, const DisplayProperties& dispProps );
void Run(); void Run();
void PushLayer();
void PopLayer();
const Display& GetDisplay(); const Display& GetDisplay();
void PushLayer( GameLayer layer );
void PushDebugLayer( GameLayer layer );
void PopTopLayer( GameLayer layer );
bool EventRecieved( GenericEvent& e ) override; bool EventRecieved( GenericEvent& e ) override;
private: public:
void PopLayer();
void PushTopLayer();
void PopDebugLayer();
private:
Display mDisplay; Display mDisplay;
Aeon::Input::Input mInput; Aeon::Input::Input mInput;
// Game layers from z order
std::vector<GameLayer> mGameLayers;
std::vector<GameLayer> mTopLayers;
std::vector<GameLayer> mDebugLayers;
private: private:
bool mSIGTERM = false; bool mSIGTERM = false;
}; };

10
Aeon/Core/Game.hpp Normal file
View File

@@ -0,0 +1,10 @@
#ifndef AEON_CORE_GAME_H_
#define AEON_CORE_GAME_H_
class Game
{
public:
};
#endif

View File

@@ -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

View File

@@ -12,8 +12,10 @@ public:
// take command line args better (parse them first!) // take command line args better (parse them first!)
ExampleGame() ExampleGame()
: App( { "Game with AEON!" } ) : App( { "Example" }, { "Game with AEON!" } )
{ {
GameLevel game;
PushLayer( game );
Run(); Run();
} }
@@ -24,6 +26,12 @@ public:
}; };
class GameLevel : public Aeon::Core::GameLayer
{
public:
};
int main( int argc, char** argv ) int main( int argc, char** argv )
{ {