diff options
author | clyne <clyne@bitgloo.com> | 2019-09-03 18:17:51 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 18:17:51 -0400 |
commit | ec1d57aeadbd0f34616eeec8f1a922ca61b90085 (patch) | |
tree | 9d2233f2437b8e85d151f9610b1a147310b9c13e /src/engine.cpp | |
parent | 0b3d24c4295bb89eb4ce3f91163cabd64d0ca6e2 (diff) | |
parent | 95cc88ad5f6c2abb4890d00a57ae4ad0db030e9b (diff) |
Merge pull request #1 from tcsullivan/save-load
Save load looks good
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 61d119a..e959f21 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -20,6 +20,7 @@ */ #include "engine.hpp" +#include "gamestate.hpp" #include "gamerun.hpp" #include "input.hpp" #include "player.hpp" @@ -30,6 +31,8 @@ #include "components/Position.hpp" #include "components/Velocity.hpp" +#include <fstream> + using namespace std::chrono_literals; namespace cr = std::chrono; typedef std::chrono::high_resolution_clock mc; @@ -43,7 +46,12 @@ int Engine::init(void) systems.add<ScriptSystem>(); systems.configure(); + // Load game script and entity data systems.system<ScriptSystem>()->init(); + if (GameState::load("save.json", entities)) { + std::cout << "Loaded from save.json. Delete the file if you don't want " + "it." << std::endl; + } return 0; } @@ -116,6 +124,9 @@ void Engine::run(void) // Done, bring logic thread back logicThread.join(); + + // Save the entities' data + GameState::save("save.json", entities); } bool Engine::shouldRun(void) |