summaryrefslogtreecommitdiffstats
path: root/src/ThreadGame.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ThreadGame.cpp35
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;
+}