aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2024-08-14 19:43:35 -0700
committer3gg <3gg@shellblade.net>2024-08-14 19:43:35 -0700
commitd0ea9cd023b7eebbee082501d8af1a1ec9af2081 (patch)
tree0da7e30ee9a511e9e66f8f28215a92d2d9449bb4
parent701d1fdb1607f336bd3a7e9ce666ca43febeadfa (diff)
Check input events once per frame.
-rw-r--r--Spear/App.hs5
1 files 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' ::
57loop' window ddt inputTimer elapsed timeBudget app = do 57loop' window ddt inputTimer elapsed timeBudget app = do
58 timer <- gameIO $ tick inputTimer 58 timer <- gameIO $ tick inputTimer
59 59
60 inputEvents <- gameIO $ pollInputEvents window
61
60 let timeBudgetThisFrame = timeBudget + deltaTime timer 62 let timeBudgetThisFrame = timeBudget + deltaTime timer
61 let steps = timeBudgetThisFrame `div` ddt 63 let steps = timeBudgetThisFrame `div` ddt
62 64
63 continue <- and <$> forM [1..steps] (\i -> do 65 continue <- and <$> forM [1..steps] (\i -> do
64 let t = timeDeltaToSec $ elapsed + i * ddt 66 let t = timeDeltaToSec $ elapsed + i * ddt
65 let dt = timeDeltaToSec ddt 67 let dt = timeDeltaToSec ddt
66 inputEvents <- gameIO $ pollInputEvents window
67 stepApp app t dt inputEvents) 68 stepApp app t dt inputEvents)
68 69
69 let elapsed' = elapsed + steps * ddt 70 let elapsed' = elapsed + steps * ddt
70 let timeBudget' = timeBudgetThisFrame `mod` ddt 71 let timeBudget' = timeBudgetThisFrame `mod` ddt
71 72
72 when continue $ do 73 when continue $ do