Estructura DX i escena logo JAILGAMES animada
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
-- Delta time helper.
|
||||
--
|
||||
-- L'ascii no exposa delta directament. Calculem en cada frame el temps
|
||||
-- transcorregut amb time() (ms des d'inici). El primer frame retornem 0
|
||||
-- per evitar salts grans, i clampem dt a 1/15 s per protegir-nos de
|
||||
-- pauses (ESC -> consola) o stalls.
|
||||
|
||||
local M = {}
|
||||
|
||||
local DT_MAX = 1.0 / 15.0 -- 66 ms; un parell de frames a 30 fps
|
||||
|
||||
local last_ms = 0
|
||||
local first = true
|
||||
|
||||
function M.reset()
|
||||
last_ms = time()
|
||||
first = true
|
||||
end
|
||||
|
||||
function M.tick()
|
||||
local now = time()
|
||||
local dt = (now - last_ms) / 1000.0
|
||||
last_ms = now
|
||||
if first then
|
||||
first = false
|
||||
return 0.0
|
||||
end
|
||||
if dt > DT_MAX then dt = DT_MAX end
|
||||
if dt < 0 then dt = 0 end
|
||||
return dt
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user