Cleanup, fix menu lock on restarting level after game over
This commit is contained in:
+15
-15
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user