Levels tick
This commit is contained in:
@@ -26,7 +26,35 @@ void App::Run()
|
||||
{
|
||||
mInput.PollInput();
|
||||
|
||||
std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
|
||||
// std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) );
|
||||
|
||||
// tick through game layers
|
||||
for ( const auto& layer : mGameLayers )
|
||||
{
|
||||
layer->FrameTick();
|
||||
}
|
||||
for ( const auto& layer : mTopLayers )
|
||||
{
|
||||
layer->FrameTick();
|
||||
}
|
||||
for ( const auto& layer : mDebugLayers )
|
||||
{
|
||||
layer->FrameTick();
|
||||
}
|
||||
|
||||
// tick through game layers *but timed*
|
||||
for ( const auto& layer : mGameLayers )
|
||||
{
|
||||
layer->TimeTick();
|
||||
}
|
||||
for ( const auto& layer : mTopLayers )
|
||||
{
|
||||
layer->TimeTick();
|
||||
}
|
||||
for ( const auto& layer : mDebugLayers )
|
||||
{
|
||||
layer->TimeTick();
|
||||
}
|
||||
|
||||
mDisplay.EndFrame();
|
||||
}
|
||||
@@ -37,6 +65,22 @@ const Display& App::GetDisplay()
|
||||
return mDisplay;
|
||||
}
|
||||
|
||||
void App::PushLayer( GameLayer* layer )
|
||||
{
|
||||
mGameLayers.push_back( layer );
|
||||
}
|
||||
|
||||
void App::PushTopLayer( GameLayer* layer )
|
||||
{
|
||||
mTopLayers.push_back( layer );
|
||||
}
|
||||
|
||||
void App::PushDebugLayer( GameLayer* layer )
|
||||
{
|
||||
mDebugLayers.push_back( layer );
|
||||
}
|
||||
|
||||
|
||||
bool App::EventRecieved( GenericEvent& e )
|
||||
{
|
||||
if ( e.Type == "DISPLAY_CLOSED" )
|
||||
|
||||
@@ -23,15 +23,15 @@ public:
|
||||
|
||||
const Display& GetDisplay();
|
||||
|
||||
void PushLayer( GameLayer layer );
|
||||
void PushDebugLayer( GameLayer layer );
|
||||
void PopTopLayer( GameLayer layer );
|
||||
void PushLayer( GameLayer* layer );
|
||||
void PushTopLayer( GameLayer* layer );
|
||||
void PushDebugLayer( GameLayer* layer );
|
||||
|
||||
bool EventRecieved( GenericEvent& e ) override;
|
||||
|
||||
public:
|
||||
void PopLayer();
|
||||
void PushTopLayer();
|
||||
void PopTopLayer();
|
||||
void PopDebugLayer();
|
||||
|
||||
private:
|
||||
@@ -39,10 +39,10 @@ private:
|
||||
|
||||
Aeon::Input::Input mInput;
|
||||
|
||||
// Game layers from z order
|
||||
std::vector<GameLayer> mGameLayers;
|
||||
std::vector<GameLayer> mTopLayers;
|
||||
std::vector<GameLayer> mDebugLayers;
|
||||
// Game layers from z orderxko285132046
|
||||
std::vector<GameLayer*> mGameLayers;
|
||||
std::vector<GameLayer*> mTopLayers;
|
||||
std::vector<GameLayer*> mDebugLayers;
|
||||
|
||||
private:
|
||||
bool mSIGTERM = false;
|
||||
|
||||
@@ -88,7 +88,7 @@ public:
|
||||
void UpdateLayer( int layer );
|
||||
|
||||
// return true = event handled
|
||||
virtual bool EventRecieved(GenericEvent& e) = 0;
|
||||
virtual bool EventRecieved( GenericEvent& e ) = 0;
|
||||
|
||||
private:
|
||||
int mListenerID = -1;
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
virtual void Attach() = 0;
|
||||
virtual void FrameTick() = 0;
|
||||
virtual void TimeTick() = 0;
|
||||
virtual void DetAttach() = 0;
|
||||
virtual void Detach() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -6,6 +6,70 @@
|
||||
#include <Aeon/Aeon.hpp>
|
||||
#include <Aeon/Core/Events.hpp>
|
||||
|
||||
class Level : public Aeon::Core::GameLayer
|
||||
{
|
||||
public:
|
||||
Level() { }
|
||||
|
||||
void Attach() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FrameTick() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TimeTick() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool EventRecieved( Aeon::Core::GenericEvent& e ) override
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Detach() override
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class TopLevel : public Aeon::Core::GameLayer
|
||||
{
|
||||
public:
|
||||
TopLevel() { }
|
||||
|
||||
void Attach() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FrameTick() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TimeTick() override
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool EventRecieved( Aeon::Core::GenericEvent& e ) override
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Detach() override
|
||||
{
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class ExampleGame : public Aeon::Core::App
|
||||
{
|
||||
public:
|
||||
@@ -14,9 +78,12 @@ public:
|
||||
ExampleGame()
|
||||
: App( { "Example" }, { "Game with AEON!" } )
|
||||
{
|
||||
GameLevel game;
|
||||
PushLayer( game );
|
||||
Level* level = new Level;
|
||||
TopLevel* topLevel = new TopLevel;
|
||||
PushLayer( (Aeon::Core::GameLayer*)level );
|
||||
PushDebugLayer( (Aeon::Core::GameLayer*)topLevel );
|
||||
Run();
|
||||
delete level;
|
||||
}
|
||||
|
||||
~ExampleGame()
|
||||
@@ -24,13 +91,6 @@ public:
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class GameLevel : public Aeon::Core::GameLayer
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
};
|
||||
|
||||
int main( int argc, char** argv )
|
||||
|
||||
Reference in New Issue
Block a user