Partially working scroll time item

This commit is contained in:
2022-10-27 18:42:38 +01:00
parent 35f2992fe4
commit c6b500c219
2 changed files with 19 additions and 7 deletions
+17 -6
View File
@@ -62,9 +62,15 @@ import SDL
import Sound.Data
import StrictHelp
{- For most menus the only way to change the world is using event handling. -}
updateUniverse :: Universe -> Universe
updateUniverse u
updateUniverse = updateUniverseLast . updateUniverseFirst
updateUniverseLast :: Universe -> Universe
updateUniverseLast = over uvWorld (mouseButtons . each .~ True) -- to determine if the mouse button is held
{- For most menus the only way to change the world is using event handling. -}
updateUniverseFirst :: Universe -> Universe
updateUniverseFirst u
| concurrentblocking = u
| otherwise = case _uvScreenLayers u of
(OptionScreen{_scOptionFlag = GameOverOptions} : _) ->
@@ -93,7 +99,12 @@ functionalUpdate' u = case u ^. uvWorld . timeFlow of
_ -> u
doTimeScroll :: Int -> World -> World
doTimeScroll smoothing w = case w ^. scrollAmount of
doTimeScroll smoothing w = case w ^? mouseButtons . ix ButtonLeft of
Just False -> w & 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
@@ -123,17 +134,17 @@ scrollTimeForward w = case w ^? timeFlow . futureWorlds . _head of
w & timeFlow . futureWorlds %~ tail
& cwTime . pastWorlds .:~ _cWorld w
& cWorld .~ cw
& timeFlow . reverseAmount +~ 1
& pointerToItemLocation (w ^?! cWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge +~ 1
& timeFlow . reverseAmount .~ ramount
& pointerToItemLocation (w ^?! cWorld . itemLocations . ix i) . itUse . leftConsumption . wpCharge .~ ramount
where
i = w ^?! timeFlow . scrollItemLocation
ramount = (w ^?! timeFlow . reverseAmount) + 1
-- | The update step.
functionalUpdate :: Universe -> Universe
functionalUpdate w =
checkEndGame
-- . updateRandGen
. over uvWorld (mouseButtons . each .~ True) -- to determine if the mouse button is held
. over uvWorld (cwTime . worldClock +~ 1)
. over uvWorld updateWorldSelect
-- . over uvWorld doRewind
+2 -1
View File
@@ -53,7 +53,7 @@ pressedMBEffectsNoInventory :: M.Map MouseButton Bool -> World -> World
pressedMBEffectsNoInventory pkeys w
| isDown ButtonLeft && isDown ButtonRight && inTopInv =
useItem (you w) w & hammers . ix DoubleMouseHam .~ HammerDown
| isDown ButtonLeft && inTopInv
| justPressedDown ButtonLeft && inTopInv
&& w ^?! hammers . ix DoubleMouseHam == HammerUp =
useLeftItem (_yourID (_cWorld w)) w
| isDown ButtonLeft && inTopInv =
@@ -68,6 +68,7 @@ pressedMBEffectsNoInventory pkeys w
inTopInv = case _hudElement (_hud (_cWorld w)) of
DisplayInventory NoSubInventory -> True
_ -> False
justPressedDown but = (pkeys ^. at but) == Just False
isDown but = but `M.member` pkeys
rotation = angleBetween (_mousePos w) (_clickMousePos w)