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

View file

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

View file

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

View file

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

View file

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

View file

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