Cleanup, fix menu lock on restarting level after game over

This commit is contained in:
2021-12-06 23:44:10 +00:00
parent 19540bd19e
commit 763b771928
18 changed files with 88 additions and 119 deletions
+15 -15
View File
@@ -6,6 +6,7 @@ module Dodge.Update
( updateUniverse
) where
import Dodge.Data
import Dodge.Menu
import Dodge.Hammer
import Dodge.Block
import Dodge.Distortion
@@ -24,27 +25,26 @@ import Data.Maybe
import Data.Function
import qualified Data.IntMap.Strict as IM
import qualified Data.Map.Strict as M
--import qualified Data.Set as S
import Control.Lens
import Data.Monoid
import System.Random
{- For most menus the only way to change the world is using event handling. -}
updateUniverse :: Universe -> Universe
updateUniverse w = case _menuLayers w of
-- (TerminalScreen t xs:mls) -> w & menuLayers .~ (TerminalScreen (max (t-1) 0) xs:mls)
updateUniverse u = case _menuLayers u of
(WaitScreen s i : _)
| i < 1 -> w & over uvWorld (dbArg _worldEvents)
| otherwise -> w & menuLayers %~ ( (WaitScreen s (i-1) :) . tail )
(OptionScreen {_scOptionFlag = GameOverOptions} : _) ->
-- updateParticles
-- . updateProjectiles
-- . updateLightSources
-- $ updateClouds
w
(_ : _) -> w
[] -> over uvWorld (functionalUpdate (_config w)) w
| i < 1 -> u & over uvWorld (dbArg _worldEvents)
| otherwise -> u & menuLayers %~ ( (WaitScreen s (i-1) :) . tail )
(OptionScreen {_scOptionFlag = GameOverOptions} : _) -> u & uvWorld %~
( updateParticles
. updateProjectiles
. updateLightSources
. updateClouds )
(_ : _) -> u
[] -> over uvWorld (functionalUpdate (_config u)) u
{- | The update step.
For most menus the only way to change the world is using event handling. -}
{- | The update step. -}
functionalUpdate :: Configuration -> World -> World
functionalUpdate cfig w = checkEndGame
. (worldClock +~ 1)
@@ -176,7 +176,7 @@ markWallSeen w wl = w { _walls = IM.adjust mw (_wlID wl) $ _walls w }
checkEndGame :: World -> World
checkEndGame w
| _crHP (you w) < 1 = undefined -- haltSound $ w {_menuLayers = [gameOverMenu]}
| _crHP (you w) < 1 = w & sideEffects %~ ( . (menuLayers .~ [gameOverMenu]))
| otherwise = w
updateClouds :: World -> World