Add menu option to start new game from seed, uses system clipboard

This commit is contained in:
2021-12-09 14:36:26 +00:00
parent eeda4f3e39
commit 24a0cc289f
13 changed files with 101 additions and 54 deletions
+18
View File
@@ -0,0 +1,18 @@
module Dodge.StartNewGame where
import Dodge.Data
import Dodge.LevelGen
import Control.Lens
import System.Random
startNewGame :: Universe -> Universe
startNewGame u = startSeedGame i u
where
i = fst $ random (_randGen (_uvWorld u))
startSeedGame :: Int -> Universe -> Universe
startSeedGame i u = u
& menuLayers .~ [WaitScreen (const "GENERATING...") 1]
& uvWorld . sideEffects .~ \_ -> do
w <- generateWorldFromSeed i
return $ u & menuLayers .~ [] & uvWorld .~ w
& savedWorlds . at LevelStartSlot ?~ w