]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
save json to file
authorClyne Sullivan <clyne@bitgloo.com>
Tue, 3 Sep 2019 17:06:58 +0000 (13:06 -0400)
committerClyne Sullivan <clyne@bitgloo.com>
Tue, 3 Sep 2019 17:06:58 +0000 (13:06 -0400)
.gitignore
src/engine.cpp

index da93793f1ce6b8801b354d5aa352b0f2a2b924fb..65892b372da2fdcfabeef7ec59f651187efe6ffd 100644 (file)
@@ -3,4 +3,5 @@ out
 .*.swp
 .*.swo
 *.o
+*.json
 
index 539515c133827352bcfd4cf603ebba411eaf499a..afd325dce5054f23b7da25305ad5d61c6c1a51c2 100644 (file)
@@ -30,6 +30,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;
@@ -117,7 +119,8 @@ void Engine::run(void)
     // Done, bring logic thread back
     logicThread.join();
 
-    cereal::JSONOutputArchive archive (std::cout);
+    std::ofstream saveFile ("save.json");
+    cereal::JSONOutputArchive archive (saveFile);
     std::string name ("entity");
     int i = 0;
     for (entityx::Entity e : entities.entities_for_debugging()) {
@@ -126,7 +129,6 @@ void Engine::run(void)
         entities.entity_serialize(e, true, archive);
         archive.finishNode();
     }
-    std::cout << std::endl;
 }
 
 bool Engine::shouldRun(void)