Skip to content

Commit

Permalink
Move initialSeed inside GameLoop class
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Nov 8, 2024
1 parent 26fb39c commit 2b130d0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
6 changes: 3 additions & 3 deletions indigo/indigo/src/main/scala/indigo/gameengine/GameLoop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"))
Expand Down

0 comments on commit 2b130d0

Please sign in to comment.