From d0ea9cd023b7eebbee082501d8af1a1ec9af2081 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Wed, 14 Aug 2024 19:43:35 -0700 Subject: Check input events once per frame. --- Spear/App.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Spear/App.hs b/Spear/App.hs index f70dd06..1a0095b 100644 --- a/Spear/App.hs +++ b/Spear/App.hs @@ -57,16 +57,17 @@ loop' :: loop' window ddt inputTimer elapsed timeBudget app = do timer <- gameIO $ tick inputTimer + inputEvents <- gameIO $ pollInputEvents window + let timeBudgetThisFrame = timeBudget + deltaTime timer let steps = timeBudgetThisFrame `div` ddt continue <- and <$> forM [1..steps] (\i -> do let t = timeDeltaToSec $ elapsed + i * ddt let dt = timeDeltaToSec ddt - inputEvents <- gameIO $ pollInputEvents window stepApp app t dt inputEvents) - let elapsed' = elapsed + steps * ddt + let elapsed' = elapsed + steps * ddt let timeBudget' = timeBudgetThisFrame `mod` ddt when continue $ do -- cgit v1.2.3