make update provide the time again

This commit is contained in:
nek0 2017-03-23 04:29:48 +01:00
parent 0963ca4f42
commit 369a74c0d0
6 changed files with 15 additions and 15 deletions

View file

@ -100,13 +100,13 @@ draw = do
handle :: SDL.EventPayload -> Affection UserData ()
handle = const $ return ()
update :: Affection UserData ()
update = do
update :: Double -> Affection UserData ()
update sec = do
traceM "updating"
ad <- get
ud@UserData{..} <- getAffection
sec <- getDelta
-- sec <- getDelta
traceM $ (show $ 1 / sec) ++ " FPS"
when (elapsedTime ad > 5) $
put $ ad

View file

@ -91,15 +91,15 @@ draw = do
UserData{..} <- getAffection
drawRect (nodeGraph M.! "nop") (G.RGB 1 0 0) Fill (G.GeglRectangle 10 10 500 500) foreground
process $ nodeGraph M.! "sink"
render Nothing Nothing
update :: Affection UserData ()
update = do
update :: Double -> Affection UserData ()
update dt = do
traceM "updating"
ud <- getAffection
-- let last = lastTick ud
-- tick <- getTick
-- putAffection $ ud { lastTick = tick }
dt <- getDelta
traceM $ (show $ 1 / dt) ++ " FPS"
elapsed <- getElapsedTime
when (elapsed > 20) $

View file

@ -134,16 +134,16 @@ draw = do
traceM "loading complete"
process (myMap M.! "sink")
present (GeglRectangle 0 0 800 600) buffer True
render Nothing Nothing
update :: Affection UserData ()
update = do
update :: Double -> Affection UserData ()
update dt = do
traceM "updating"
tick <- getElapsedTime
ud <- getAffection
putAffection $ ud { lastTick = tick }
let dt = tick - lastTick ud
return ()
traceM $ (show $ 1 / dt) ++ " FPS"

View file

@ -108,15 +108,15 @@ draw = do
process (nodeGraph M.! "sink")
present (GeglRectangle 0 0 800 600) foreground True
update :: Affection UserData ()
update = do
update :: Double -> Affection UserData ()
update dt = do
traceM "updating"
tick <- getElapsedTime
ud <- getAffection
putAffection $ ud { lastTick = tick }
let dt = tick - lastTick ud
-- let dt = tick - lastTick ud
return ()
traceM $ show (1 / dt) ++ " FPS"

View file

@ -100,8 +100,8 @@ draw = do
foreground
True
update :: Affection UserData ()
update = do
update :: Double -> Affection UserData ()
update dt = do
traceM "updating"
ad <- get
ud <- getAffection

View file

@ -59,7 +59,7 @@ data AffectionConfig us = AffectionConfig
-- ^ Actions to be performed, before loop starts
, eventLoop :: SDL.EventPayload -> Affection us ()
-- ^ Main update function. Takes fractions of a second as input.
, updateLoop :: Affection us ()
, updateLoop :: Double -> Affection us ()
-- ^ Main update function. Takes fractions of a second as input.
, drawLoop :: Affection us ()
-- ^ Function for updating graphics.