Files
YataiDON14/Scripts/result/result_transition.lua
T
2026-10-02 14:07:44 +08:00

50 lines
2.2 KiB
Lua

-- YataiDONNantoka game -> result transition: taikonantoka's Play/Load/bg_end.png wipe.
-- The engine's ResultTransition calls new / start / update / draw / is_finished and, when
-- draw exists, skips its own shutter. taikonantoka starts the wipe when the song audio
-- stops (play-loop state 9): Scripts/background/background.lua starts it then and stores
-- the start in the shared global NK_PLAY_WIPE_MS; if the engine's transition comes first
-- (end_time + 8533 ms), the wipe starts here. y = 480 - 0.96 d, -480 from d = 1000 ms
-- (asm 0x41C229); taikonantoka switches scene at 1000 ms, the engine after its move
-- animation (983 ms) and the result_transition voice -- the wipe's bottom half covers the
-- whole screen from d = 500 ms, and the result screen opens on Result/Load/bg_start at y 0.
ResultTransition = {}
ResultTransition.__index = ResultTransition
-- Resolution independence: 640x480 px distances times K = screen width / 640 (integer 1 at
-- 640 wide, so the native skin keeps the same arithmetic).
local K = tex.get_screen_width() / 640
K = math.tointeger(K) or K
local SH, SPEED = 480 * K, 0.96 * K -- screen height, wipe speed (px per ms)
function ResultTransition.new(player_num)
local self = setmetatable({}, ResultTransition)
tex.load_folder("background", "nk_load")
self.id = tex.get_texture("background/nk_load/bg_end")
self.now = nil
self.started = false
NK_PLAY_WIPE_MS = nil -- a new play screen: forget the previous song's wipe
return self
end
function ResultTransition:start()
self.started = true
end
function ResultTransition:update(current_ms)
self.now = current_ms
if self.started and not self.t0 then self.t0 = current_ms end
end
-- The wipe starts with the engine's transition (not when the BGM stops): only this layer is
-- drawn above the engine's song title, and the user wants no title on the transition.
function ResultTransition:draw()
if not (self.id and self.now and self.t0) then return end
local d = self.now - self.t0
tex.draw_texture(self.id, { x = 0, y = (d < 1000) and (SH - d * SPEED) or -SH })
end
function ResultTransition:is_finished()
return false -- the engine's move animation and voice decide
end