From ff91fdb969833e88124122b41a7cd77be9e59e69 Mon Sep 17 00:00:00 2001 From: davesmith00000 Date: Fri, 8 Nov 2024 14:11:36 +0000 Subject: [PATCH] Move initialSeed inside GameLoop class --- .../src/main/scala/indigo/gameengine/GameEngine.scala | 4 ++-- .../indigo/src/main/scala/indigo/gameengine/GameLoop.scala | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/indigo/indigo/src/main/scala/indigo/gameengine/GameEngine.scala b/indigo/indigo/src/main/scala/indigo/gameengine/GameEngine.scala index a1a1fec5d..2c5210fd0 100644 --- a/indigo/indigo/src/main/scala/indigo/gameengine/GameEngine.scala +++ b/indigo/indigo/src/main/scala/indigo/gameengine/GameEngine.scala @@ -178,12 +178,12 @@ final class GameEngine[StartUpData, GameModel, ViewModel]( audioPlayer.addAudioAssets(accumulatedAssetCollection.sounds) - val time = (if (firstRun) 0 else gameLoopInstance.runningTimeReference) + gameLoopInstance.initialSeed + val randomSeed = (if (firstRun) 0 else gameLoopInstance.runningTimeReference) + gameLoopInstance.initialSeed if (firstRun) platform = new Platform(parentElement, gameConfig, globalEventStream, dynamicText) - initialise(accumulatedAssetCollection)(Dice.fromSeed(time.toLong)) match { + initialise(accumulatedAssetCollection)(Dice.fromSeed(randomSeed.toLong)) match { case oe @ Outcome.Error(error, _) => IndigoLogger.error( if (firstRun) "Error during first initialisation - Halting." diff --git a/indigo/indigo/src/main/scala/indigo/gameengine/GameLoop.scala b/indigo/indigo/src/main/scala/indigo/gameengine/GameLoop.scala index 5d52e021c..8ad113980 100644 --- a/indigo/indigo/src/main/scala/indigo/gameengine/GameLoop.scala +++ b/indigo/indigo/src/main/scala/indigo/gameengine/GameLoop.scala @@ -24,8 +24,6 @@ import scala.collection.mutable import scala.scalajs.js.Date import scala.scalajs.js.JSConverters._ -val initialDate = new Date() - final class GameLoop[StartUpData, GameModel, ViewModel]( rebuildGameLoop: AssetCollection => Unit, boundaryLocator: BoundaryLocator, @@ -38,7 +36,9 @@ final class GameLoop[StartUpData, GameModel, ViewModel]( startFrameLocked: Boolean, renderer: => Renderer ): - val initialSeed = initialDate.valueOf() + + val initialSeed = new Date().valueOf() + @SuppressWarnings(Array("scalafix:DisableSyntax.var")) private var _gameModelState: GameModel = initialModel @SuppressWarnings(Array("scalafix:DisableSyntax.var"))