23 lines
903 B
Lua
23 lines
903 B
Lua
-- Loading screen countdown: kidou/countdown frames 0-9 are the digits, frame 10 the separator,
|
|
-- drawn as S"CC (seconds, hundredths) counting down. `seconds` is how long the screen stays at
|
|
-- least (0 = no countdown); x is the centre, y the top, pitch the distance between digits.
|
|
|
|
local M = { seconds = 10 }
|
|
|
|
function M.draw(left_ms)
|
|
local secs = math.floor(left_ms / 1000)
|
|
local hundredths = math.floor(left_ms / 10) % 100
|
|
local frames = {}
|
|
for c in tostring(secs):gmatch(".") do frames[#frames + 1] = tonumber(c) end
|
|
frames[#frames + 1] = 10
|
|
frames[#frames + 1] = hundredths // 10
|
|
frames[#frames + 1] = hundredths % 10
|
|
local sprite = tex.get_texture("loading/kidou/countdown")
|
|
local x0 = 480 - 24.75 * #frames / 2
|
|
for i, frame in ipairs(frames) do
|
|
tex.draw_texture(sprite, { frame = frame, x = x0 + 24.75 * (i - 1), y = 530 })
|
|
end
|
|
end
|
|
|
|
return M
|