Layers ARE EVENT LISTENERS??? *whaaat*
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "Aeon/Aeon.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
@@ -2,9 +2,11 @@
|
||||
#define AEON_AEON_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#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;
|
||||
|
||||
private:
|
||||
// Game layers from z order
|
||||
std::vector<GameLayer> mGameLayers;
|
||||
std::vector<GameLayer> mTopLayers;
|
||||
std::vector<GameLayer> mDebugLayers;
|
||||
|
||||
private:
|
||||
bool mSIGTERM = false;
|
||||
|
||||
};
|
||||
|
||||
10
Aeon/Core/Game.hpp
Normal file
10
Aeon/Core/Game.hpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef AEON_CORE_GAME_H_
|
||||
#define AEON_CORE_GAME_H_
|
||||
|
||||
class Game
|
||||
{
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -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
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user