Add frame clock

This commit is contained in:
2021-09-09 13:29:09 +01:00
parent a2288110ae
commit be7b2d2cd7
27 changed files with 176 additions and 87 deletions
+13 -7
View File
@@ -14,20 +14,25 @@ import Data.Aeson (encodeFile)
{- |
Write the current world configuration to disk as a json file.
-}
saveConfig :: Configuration -> PreloadData -> IO PreloadData
saveConfig cfig d = do
saveConfig :: Configuration -> (a -> IO a) -> a -> IO a
saveConfig cfig f x = do
putStrLn "Saving config to data/dodge.config.json"
encodeFile "data/dodge.config.json" cfig
return d
f x
{- |
Apply the volume settings from the world configuration to the running game.
-}
setVol :: Configuration -> PreloadData -> IO PreloadData
setVol cfig d = do
setVol :: Configuration -> IO ()
setVol cfig = do
setSoundVolume ( _volume_master cfig * _volume_sound cfig)
setMusicVolume ( _volume_master cfig * _volume_music cfig)
return d
setVol' :: Configuration -> (a -> IO a) -> a -> IO a
setVol' cfig f a = do
setVol cfig
f a
{- |
Apply /all/ of the values in the world configuration to the running game.
@@ -37,7 +42,8 @@ applyWorldConfig
-> PreloadData
-> IO PreloadData
applyWorldConfig cfig pdata = do
setVol cfig pdata >>= pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y
setVol cfig
pdataResizeUpdate (x `div` divRes) (y `div` divRes) x y pdata
where
x = round $ _windowX cfig
y = round $ _windowY cfig