Skip to content

Instantly share code, notes, and snippets.

@sponge
Created January 21, 2018 23:51
Show Gist options
  • Save sponge/dbf30b5a2e8cacf19fc78147f7abe402 to your computer and use it in GitHub Desktop.
Save sponge/dbf30b5a2e8cacf19fc78147f7abe402 to your computer and use it in GitHub Desktop.
--
-- UPDATE
--
local accum = 0
function Game:update(dt)
accum = accum + dt
if (accum < 1/60) then
return
end
-- just skip frames if we slow down (window dragging)
while (accum > 1/60) do
accum = accum - 1/60
end
dt = 1/60
self.controls:update()
self.timer = self.timer + dt
self.levelTimer = self.levelTimer + dt
if self.controls:pressed('pause') then
self:togglePause()
end
if not self.paused then
self:updateEntities(dt)
end
self:removeEntities()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment