added random seed
authorNils Forssén <nilfo359@student.liu.se>
Tue, 12 Dec 2023 09:27:57 +0000 (10:27 +0100)
committerNils Forssén <nilfo359@student.liu.se>
Tue, 12 Dec 2023 09:27:57 +0000 (10:27 +0100)
assets/data.json
play
src/_main.cc

index 79aed33a1d7b7c9040444abd0aeedfc805fe98f2..54adbb92df8af346bd10f977d914675dd8256d88 100644 (file)
@@ -52,7 +52,8 @@
         "yf_per_second": 0.25,
         "bikes_per_second": 0.25,
         "point_scale_div": 3.0,
-        "highscore_file": "assets/highscore.csv"
+        "highscore_file": "assets/highscore.csv",
+        "random_seed": 234234
     },
     "map": {
         "points_pos": [
diff --git a/play b/play
index 0f1e5c00d7bafcda755262858aa0599e9283fde5..e382014e2f7e7ba15617d70545ea81949c51c05e 100755 (executable)
Binary files a/play and b/play differ
index 127f55221afa711ea0d388e3d28f424b1a6e7c78..9322f3f548785919613a9cfc5a77061c74432f91 100644 (file)
@@ -29,6 +29,7 @@ int main ()
     
     std::ifstream f("assets/data.json");
     json data = json::parse(f);
+    srand(data["game_constants"]["random_seed"]);
     game_context.current_state = std::make_unique<Start_menu>(data);
     f.close();
 
@@ -59,8 +60,6 @@ int main ()
         {
             game_context.current_state = std::move(game_context.next_state);
             game_context.next_state = nullptr;
-
-            srand(game_clock.getElapsedTime().asMicroseconds());
         }
 
         //Draw