Move in game key press input reaction to universe update

This commit is contained in:
2022-10-30 10:19:59 +00:00
parent e3155752ba
commit 9779b6fa39
9 changed files with 97 additions and 54 deletions
+10 -2
View File
@@ -7,8 +7,7 @@ Description : Simulation update
module Dodge.Update (updateUniverse) where
import Color
--import Dodge.Zone
import Dodge.Update.Input
import Dodge.Update.Scroll
import Control.Applicative
import Data.List
@@ -65,14 +64,23 @@ import StrictHelp
updateUniverse :: Universe -> Universe
updateUniverse u = updateUniverseLast . updateUniverseMid
. updateUseInput
. over uvWorld (updateCamera cfig)
. over (uvWorld . cWorld . cClock) ( + 1)
$ updateBounds u -- where should this go? next to update camera?
where
cfig = u ^. uvConfig
updateUseInput :: Universe -> Universe
updateUseInput u = M.foldlWithKey' updateKeyInGame u (u ^. uvWorld . input . pressedKeys)
updateUniverseLast :: Universe -> Universe
updateUniverseLast = over uvWorld (input . mouseButtons . each .~ True) -- to determine if the mouse button is held
. over uvWorld (input . pressedKeys . each %~ f)
where
f LongPress = LongPress
f _ = ShortPress
{- For most menus the only way to change the world is using event handling. -}
updateUniverseMid :: Universe -> Universe