summary refs log tree commit diff
path: root/lib/main.fnl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/main.fnl')
-rw-r--r--lib/main.fnl29
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/main.fnl b/lib/main.fnl
index bc3be16..8185f10 100644
--- a/lib/main.fnl
+++ b/lib/main.fnl
@@ -50,18 +50,23 @@
           (table.remove messages i)
           (set v.ticks (- v.ticks 1))))))
 
-(fn love.update []
-  (music.pre-update)
-  ;; TODO: make state changes actually possible
-  (match (pcall #(state.update the-state))
-    (true next) (global the-state next)
-    (true nil) nil
-    (false x) (do
-                (print (.. "update: \n" x))
-                (table.insert messages
-                              {:ticks 1
-                               :msg (.. "update: \n" x)})))
-  (music.update))
+(var dt-acc 0)
+
+(fn love.update [dt]
+  (set dt-acc (math.min (/ 20) (+ dt-acc dt)))
+  (while (> dt-acc (/ 60))
+    (set dt-acc (- dt-acc (/ 60)))
+    (music.pre-update)
+    ;; TODO: make state changes actually possible
+    (match (pcall #(state.update the-state))
+      (true next) (global the-state next)
+      (true nil) nil
+      (false x) (do
+                  (print (.. "update: \n" x))
+                  (table.insert messages
+                                {:ticks 1
+                                 :msg (.. "update: \n" x)})))
+    (music.update)))
 
 (fn love.mousepressed [x y button]
   (match (pcall #(state.mousepressed the-state x y button))