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"))