diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2022-11-03 21:02:31 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2022-11-03 21:02:31 -0700 |
commit | 0e0f36f8b4a57bd9a13925c9f7e92f7bd8c59a81 (patch) | |
tree | a4fc9dc7350d4d5d4d5f4ec8d4a2cbe96c400db0 /main.lua | |
parent | d1dd3e441f35a2f54b699e7a3a1874a4788f8ed5 (diff) | |
download | view.love-0e0f36f8b4a57bd9a13925c9f7e92f7bd8c59a81.tar.gz |
stop tracking wallclock time
We only need time differences.
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/main.lua b/main.lua index 570a7a1..7c3a482 100644 --- a/main.lua +++ b/main.lua @@ -81,8 +81,9 @@ function App.initialize_globals() end -- for hysteresis in a few places - Last_focus_time = App.getTime() -- https://love2d.org/forums/viewtopic.php?p=249700 - Last_resize_time = App.getTime() + Current_time = 0 + Last_focus_time = 0 -- https://love2d.org/forums/viewtopic.php?p=249700 + Last_resize_time = 0 end function App.initialize(arg) @@ -103,7 +104,7 @@ function App.resize(w,h) else assert(false, 'unknown app "'..Current_app..'"') end - Last_resize_time = App.getTime() + Last_resize_time = Current_time end function App.filedropped(file) @@ -118,7 +119,7 @@ end function App.focus(in_focus) if in_focus then - Last_focus_time = App.getTime() + Last_focus_time = Current_time end if Current_app == 'run' then if run.focus then run.focus(in_focus) end @@ -140,8 +141,9 @@ function App.draw() end function App.update(dt) + Current_time = Current_time + dt -- some hysteresis while resizing - if App.getTime() < Last_resize_time + 0.1 then + if Current_time < Last_resize_time + 0.1 then return end -- @@ -156,7 +158,7 @@ end function App.keychord_pressed(chord, key) -- ignore events for some time after window in focus (mostly alt-tab) - if App.getTime() < Last_focus_time + 0.01 then + if Current_time < Last_focus_time + 0.01 then return end -- @@ -194,7 +196,7 @@ end function App.textinput(t) -- ignore events for some time after window in focus (mostly alt-tab) - if App.getTime() < Last_focus_time + 0.01 then + if Current_time < Last_focus_time + 0.01 then return end -- @@ -209,7 +211,7 @@ end function App.keyreleased(chord, key) -- ignore events for some time after window in focus (mostly alt-tab) - if App.getTime() < Last_focus_time + 0.01 then + if Current_time < Last_focus_time + 0.01 then return end -- |