Files
PyTaikoGreen/Scripts/global/result_transition.lua
T
2026-09-30 12:42:40 -04:00

73 lines
3.1 KiB
Lua

ResultTransition = {}
ResultTransition.__index = ResultTransition
function ResultTransition.new(player_num)
local self = setmetatable({}, ResultTransition)
self.player_num = player_num
self.move = tex.get_animation(5, "global") -- result shutter move in
local screen_w = tex.get_screen_width()
if player_num == 3 then -- PlayerNum.TWO_PLAYER
self.t_shutter_1p = tex.get_texture("global/result_transition/1p_shutter")
self.t_shutter_2p = tex.get_texture("global/result_transition/2p_shutter")
self.t_footer_1p = tex.get_texture("global/result_transition/1p_shutter_footer")
self.t_footer_2p = tex.get_texture("global/result_transition/2p_shutter_footer")
self.has_footer = self.t_footer_1p ~= nil and self.t_footer_2p ~= nil
local f1 = tex.get_texture_info("result_transition", "1p_shutter_footer")
local f2 = tex.get_texture_info("result_transition", "2p_shutter_footer")
self.tex_height = (f1 and f1.height) or 0
self.tex_height_2p = (f2 and f2.height) or 0
local s = tex.get_texture_info("result_transition", "1p_shutter")
self.shutter_width = (s and s.width) or (screen_w / 5)
else
local ps = (player_num == 2) and "2p" or "1p" -- PlayerNum.P2, else 1p
self.t_shutter = tex.get_texture("global/result_transition/" .. ps .. "_shutter")
self.t_footer = tex.get_texture("global/result_transition/" .. ps .. "_shutter_footer")
self.has_footer = self.t_footer ~= nil
local f = tex.get_texture_info("result_transition", ps .. "_shutter_footer")
self.tex_height = (f and f.height) or 0
local s = tex.get_texture_info("result_transition", ps .. "_shutter")
self.shutter_width = (s and s.width) or (screen_w / 5)
end
return self
end
function ResultTransition:start()
self.move:start()
end
function ResultTransition:update(current_ms)
self.move:update(current_ms)
end
function ResultTransition:is_finished()
return false -- the engine's move animation and result_transition voice decide
end
function ResultTransition:draw()
if not self.has_footer then return end
local attr = self.move.attribute
local screen_h = tex.get_screen_height()
local screen_w = tex.get_screen_width()
local x = 0
while x < screen_w do
if self.player_num == 3 then
tex.draw_texture(self.t_shutter_1p, { x = x, y = -screen_h + attr })
tex.draw_texture(self.t_shutter_2p, { x = x, y = screen_h - attr })
tex.draw_texture(self.t_footer_1p, { x = x, y = -(self.tex_height * 3) + attr })
tex.draw_texture(self.t_footer_2p, { x = x, y = screen_h + (self.tex_height_2p * 2) - attr })
else
tex.draw_texture(self.t_shutter, { x = x, y = -screen_h + attr })
tex.draw_texture(self.t_shutter, { x = x, y = screen_h - attr })
tex.draw_texture(self.t_footer, { x = x, y = -(self.tex_height * 3) + attr })
tex.draw_texture(self.t_footer, { x = x, y = screen_h + (self.tex_height * 2) - attr })
end
x = x + self.shutter_width
end
end