Stop all sound when stopping time
This commit is contained in:
+28
-29
@@ -94,59 +94,59 @@ functionalUpdate'' :: Universe -> Universe
|
||||
functionalUpdate'' = advanceScrollAmount . functionalUpdate'
|
||||
|
||||
functionalUpdate' :: Universe -> Universe
|
||||
functionalUpdate' u = case u ^. uvWorld . timeFlow of
|
||||
functionalUpdate' u = case u ^. uvWorld . cWorld . timeFlow of
|
||||
NormalTimeFlow -> functionalUpdate u
|
||||
ScrollTimeFlow smoothing _ _ _ -> over uvWorld (doTimeScroll smoothing) u
|
||||
_ -> u
|
||||
|
||||
doTimeScroll :: Int -> World -> World
|
||||
doTimeScroll smoothing w = case w ^? mouseButtons . ix ButtonLeft of
|
||||
Just False -> w & timeFlow .~ NormalTimeFlow
|
||||
Just False -> w & cWorld . timeFlow .~ NormalTimeFlow
|
||||
_ -> doTimeScroll' smoothing w
|
||||
|
||||
doTimeScroll' :: Int -> World -> World
|
||||
doTimeScroll' smoothing w = case w ^. scrollAmount of
|
||||
x | x > 1 -> w & scrollTimeBack & timeFlow . scrollSmoothing .~ 20
|
||||
x | x > 0 -> w & scrollTimeBack & timeFlow . scrollSmoothing %~ max 0
|
||||
x | x < (-1) -> w & scrollTimeForward & timeFlow . scrollSmoothing .~ negate 20
|
||||
x | x < 0 -> w & scrollTimeForward & timeFlow . scrollSmoothing %~ min 0
|
||||
_ | smoothing > 0 -> scrollTimeBack w & timeFlow . scrollSmoothing -~ 1
|
||||
_ | smoothing < 0 -> scrollTimeForward w & timeFlow . scrollSmoothing +~ 1
|
||||
x | x > 1 -> w & scrollTimeBack & cWorld . timeFlow . scrollSmoothing .~ 20
|
||||
x | x > 0 -> w & scrollTimeBack & cWorld . timeFlow . scrollSmoothing %~ max 0
|
||||
x | x < (-1) -> w & scrollTimeForward & cWorld .timeFlow . scrollSmoothing .~ negate 20
|
||||
x | x < 0 -> w & scrollTimeForward & cWorld .timeFlow . scrollSmoothing %~ min 0
|
||||
_ | smoothing > 0 -> scrollTimeBack w & cWorld .timeFlow . scrollSmoothing -~ 1
|
||||
_ | smoothing < 0 -> scrollTimeForward w & cWorld .timeFlow . scrollSmoothing +~ 1
|
||||
_ -> w
|
||||
|
||||
scrollTimeBack :: World -> World
|
||||
scrollTimeBack w = case w ^? cwTime . pastWorlds . _head of
|
||||
scrollTimeBack w = case w ^? cWorld . pastWorlds . _head of
|
||||
Nothing -> w
|
||||
Just cw -> case w ^?! timeFlow . reverseAmount of
|
||||
Just lw -> case w ^?! cWorld .timeFlow . reverseAmount of
|
||||
x | x > 0 ->
|
||||
w & cwTime . pastWorlds %~ tail
|
||||
& timeFlow . futureWorlds .:~ _cWorld w
|
||||
& timeFlow . reverseAmount -~ 1
|
||||
& cWorld .~ cw
|
||||
w & cWorld . pastWorlds %~ tail
|
||||
& cWorld .timeFlow . futureWorlds .:~ (w ^. cWorld . lWorld)
|
||||
& cWorld .timeFlow . reverseAmount -~ 1
|
||||
& cWorld . lWorld .~ lw
|
||||
& pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ (x -1)
|
||||
_ -> w
|
||||
where
|
||||
i = w ^?! timeFlow . scrollItemLocation
|
||||
i = w ^?! cWorld . timeFlow . scrollItemLocation
|
||||
|
||||
scrollTimeForward :: World -> World
|
||||
scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of
|
||||
scrollTimeForward w = case w ^? cWorld . timeFlow . futureWorlds . _head of
|
||||
Nothing -> w
|
||||
Just cw ->
|
||||
w & timeFlow . futureWorlds %~ tail
|
||||
& cwTime . pastWorlds .:~ _cWorld w
|
||||
& cWorld .~ cw
|
||||
& timeFlow . reverseAmount .~ ramount
|
||||
Just lw ->
|
||||
w & cWorld . timeFlow . futureWorlds %~ tail
|
||||
& cWorld . pastWorlds .:~ (w ^. cWorld . lWorld)
|
||||
& cWorld . lWorld .~ lw
|
||||
& cWorld . timeFlow . reverseAmount .~ ramount
|
||||
& pointerToItemLocation (w ^?! cWorld . lWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount
|
||||
where
|
||||
i = w ^?! timeFlow . scrollItemLocation
|
||||
ramount = (w ^?! timeFlow . reverseAmount) + 1
|
||||
i = w ^?! cWorld . timeFlow . scrollItemLocation
|
||||
ramount = (w ^?! cWorld . timeFlow . reverseAmount) + 1
|
||||
|
||||
-- | The update step.
|
||||
functionalUpdate :: Universe -> Universe
|
||||
functionalUpdate w =
|
||||
checkEndGame
|
||||
-- . updateRandGen
|
||||
. over uvWorld (cwTime . worldClock +~ 1)
|
||||
. over uvWorld (cWorld . lWorld . lClock +~ 1)
|
||||
. over uvWorld updateWorldSelect
|
||||
-- . over uvWorld doRewind
|
||||
-- . over uvWorld (hammers . each %~ moveHammerUp)
|
||||
@@ -215,7 +215,7 @@ advanceScrollAmount u =
|
||||
& uvWorld . scrollAmount .~ 0
|
||||
|
||||
updatePastWorlds :: World -> World
|
||||
updatePastWorlds w = w & cwTime . pastWorlds %~ (forceFoldable . take 100 . (_cWorld w :))
|
||||
updatePastWorlds w = w & cWorld . pastWorlds %~ (forceFoldable . take 100 . ((w ^. cWorld . lWorld) :))
|
||||
|
||||
moveHammersUp :: Universe -> Universe
|
||||
--moveHammersUp = uvWorld . hammers .~ M.empty
|
||||
@@ -537,13 +537,12 @@ markSeen :: Wall -> Wall
|
||||
markSeen wl = wl{_wlSeen = True}
|
||||
|
||||
checkEndGame :: Universe -> Universe
|
||||
checkEndGame uv = case w ^. cwTime . deathDelay of
|
||||
checkEndGame uv = case w ^? cWorld . timeFlow . deathDelay of
|
||||
Just x
|
||||
| x < 0 ->
|
||||
uv & uvScreenLayers .~ [gameOverMenu]
|
||||
& uvWorld . cwTime . deathDelay .~ Nothing
|
||||
Just _ -> uv & uvWorld . cwTime . deathDelay . _Just -~ 1
|
||||
_ | _crHP (you w) < 1 -> uv & uvWorld . cwTime . deathDelay ?~ 50
|
||||
Just _ -> uv & uvWorld . cWorld . timeFlow . deathDelay -~ 1
|
||||
_ | _crHP (you w) < 1 -> uv & uvWorld . cWorld . timeFlow .~ DeathTime 50
|
||||
_ -> uv
|
||||
where
|
||||
w = _uvWorld uv
|
||||
|
||||
Reference in New Issue
Block a user