Fix start new game bug

This commit is contained in:
2021-12-07 00:02:21 +00:00
parent 763b771928
commit d8b416191f
+16 -16
View File
@@ -1,7 +1,5 @@
module Dodge.Menu
( scodeToChar
, popScreen
, pushScreen
, pauseMenu
, gameOverMenu
) where
@@ -13,7 +11,7 @@ import Dodge.PreloadData
import Dodge.Save
import Dodge.Config.Update
import SDL
import SDL.Internal.Numbered
--import SDL.Internal.Numbered
--import Preload.Update
import Dodge.SoundLogic
import Dodge.LevelGen
@@ -124,29 +122,29 @@ gameOverMenu = OptionScreen
, _scOptionFlag = GameOverOptions
}
--startNewGame' :: Universe -> IO (Maybe Universe)
--startNewGame' u = do
-- w <- generateWorldFromSeed i
-- return $ Just (u & uvWorld .~ w)
-- where
-- i = fst $ random (_randGen (_uvWorld u))
startNewGame :: Universe -> Maybe Universe
startNewGame w = Just $ w
startNewGame u = Just $ u
& menuLayers .~ [WaitScreen (const "GENERATING...") 1]
& uvWorld . sideEffects .~ \u -> do
w' <- generateWorldFromSeed i
return (u & uvWorld .~ w')
& uvWorld . sideEffects .~ \_ -> do
w <- generateWorldFromSeed i
return (u & menuLayers .~ [] & uvWorld .~ w)
where
i = fst $ random (_randGen (_uvWorld w))
i = fst $ random (_randGen (_uvWorld u))
-- | hacky
scodeToChar :: Scancode -> Char
scodeToChar = toEnum . (+ 61) . fromIntegral . toNumber
scodeToChar = toEnum . (+ 61) . fromIntegral . unwrapScancode
--charToScode :: Char -> Scancode
--charToScode = Scancode . fromIntegral . (\x -> x - 61) . fromEnum
--levelMenu :: Int -> ScreenLayer
--levelMenu x = OptionScreen
-- { _scTitle = const $ "LEVEL "++ show x
-- , _scOptions = levelMenuOptions
-- , _scDefaultEff = unpause . storeLevel
-- , _scOptionFlag = NormalOptions
-- }
unpause :: Universe -> Maybe Universe
unpause w = Just . resumeSound $ w & menuLayers .~ []
@@ -162,6 +160,8 @@ listControls =
,("[space]" , "PICKUP ITEM" )
,("m" , "DISPLAY MAP" )
,("f" , "DROP ITEM" )
,("c" , "COMBINE ITEMS" )
,("x" , "TWEAK ITEMS" )
,("c[esc]" , "PAUSE" )
,("qe" , "ROTATE CAMERA")
,("F5" , "QUICKSAVE")