diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-03 17:03:59 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-08-03 17:03:59 +0200 |
commit | f7decf41d8d0062901cd39c42a3669a80537c7df (patch) | |
tree | d3032265df11eee6e3eaf8b4b081524bef5e72b2 /src/ThreadGame.cpp | |
parent | 2017-07-29 (diff) | |
download | AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.gz AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.bz2 AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.lz AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.xz AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.tar.zst AltCraft-f7decf41d8d0062901cd39c42a3669a80537c7df.zip |
Diffstat (limited to 'src/ThreadGame.cpp')
-rw-r--r-- | src/ThreadGame.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/ThreadGame.cpp b/src/ThreadGame.cpp new file mode 100644 index 0000000..03c2c14 --- /dev/null +++ b/src/ThreadGame.cpp @@ -0,0 +1,35 @@ +#include "ThreadGame.hpp" + + +ThreadGame::ThreadGame() { + +} + +ThreadGame::~ThreadGame() { + +} + +void ThreadGame::Execute() { + + EventListener listener; + + listener.RegisterHandler(EventType::GlobalAppState, [this](EventData eventData) { + auto data = std::get<GlobalAppStateData>(eventData); + state = data.state; + }); + + listener.RegisterHandler(EventType::ConnectionSuccessfull, [this](EventData eventData) { + auto data = std::get<ConnectionSuccessfullData>(eventData); + gs = new GameState(data.ptr); + }); + + LoopExecutionTimeController timer(std::chrono::milliseconds(int(1.0f / 60.0f * 1000.0f))); + + while (state != GlobalState::Exiting) { + listener.HandleEvent(); + if (gs != nullptr) + gs->Update(timer.GetDeltaMs()); + timer.Update(); + } + delete gs; +} |