Fix new game resize bug

This commit is contained in:
jgk
2021-04-22 10:11:26 +02:00
parent 50e957818f
commit 60b2327909
6 changed files with 32 additions and 9 deletions
+8 -6
View File
@@ -7,6 +7,7 @@ import Dodge.Initialisation
import Dodge.SoundLogic
import Dodge.Config.Data
import Dodge.Config.Update
import Dodge.Layout
import Data.Maybe
import qualified Data.Set as S
@@ -23,17 +24,14 @@ handlePressedKeyInMenu mState scode w = case mState of
PauseMenu -> case scode of
ScancodeEscape -> Nothing
ScancodeR -> return $ fromMaybe w $ _storedLevel w
ScancodeN -> Just $ putSound $ generateLevel 1
$ initialWorld {_randGen = _randGen w}
ScancodeN -> startNewGame
ScancodeO -> goToOptionMenu w
ScancodeC -> goToControls w
_ -> unpause w
GameOverMenu -> case scode of
ScancodeEscape -> Nothing
ScancodeR -> Just $ fromMaybe w $ _storedLevel w
ScancodeN -> Just $ putSound $ generateLevel 1
$ initialWorld
{_randGen = _randGen w}
ScancodeN -> startNewGame
ScancodeO -> goToOptionMenu w
ScancodeC -> goToControls w
_ -> Just w
@@ -52,12 +50,16 @@ handlePressedKeyInMenu mState scode w = case mState of
unpause w' = Just . resumeSound $
w' {_menuLayers = []}
startLevel = unpause . storeLevel
putSound = id -- set loadedSounds (_loadedSounds w)
dec x = max 0 (x - 0.1)
inc x = min 1 (x + 0.1)
goToOptionMenu w = Just $ w & menuLayers %~ (OptionMenu :)
goToControls w = Just $ w & menuLayers %~ (ControlList :)
sw = w & sideEffects %~ (setVol (_config w) : )
startNewGame = Just $ generateFromList levx
$ initialWorld
& randGen .~ _randGen w
& windowX .~ _windowX w
& windowY .~ _windowY w
storeLevel :: World -> World
storeLevel w = case _storedLevel w of