From b9b771bc1ccccbdd4a7c27d4e56c4fd4dd1413ed Mon Sep 17 00:00:00 2001 From: Trianta <56975502+Trimutex@users.noreply.github.com> Date: Fri, 2 Aug 2024 19:50:48 -0500 Subject: [PATCH] refactor: convert engine to a singleton --- src/gamestate.hpp | 2 ++ src/main.cpp | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/gamestate.hpp b/src/gamestate.hpp index cbee036..ec9e118 100755 --- a/src/gamestate.hpp +++ b/src/gamestate.hpp @@ -39,4 +39,6 @@ private: double average = 0; }; +inline std::unique_ptr g_pEngine; + #endif diff --git a/src/main.cpp b/src/main.cpp index a26a74d..cdf6822 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,8 +1,9 @@ -#include "gamestate.hpp" - -int main(void) -{ - GameEngine game; - game.Start(); - return 0; -} +#include "gamestate.hpp" +#include + +int main(void) +{ + g_pEngine = std::make_unique(); + g_pEngine->Start(); + return 0; +}