Files
YataiDON14/Scripts/entry/player.lua
T
2026-11-22 19:25:31 -05:00

79 lines
2.9 KiB
Lua

-- Taiko 14 player_entry.swg join: the drum rises out of the floor, Don (left) or Katsu (right) flies up onto it
-- and the 参加 fan rises behind. The 3D model is not used: draw_drum_back draws the 2D art. Positions are the
-- swg's 640x480 px (K scales them), times are 60 fps frames from the join.
EntryPlayer = {}
EntryPlayer.__index = EntryPlayer
local K = tex.get_screen_width() / 640
local FRAME_MS = 1000 / 60
local function clamp(v, lo, hi) return math.max(lo, math.min(hi, v)) end
local function lerp(a, b, p) return a + (b - a) * p end
local function ease_out(p) return 1 - (1 - p) * (1 - p) end
local function ease_in(p) return p * p end
local function seg(t, from, len) return clamp((t - from) / len, 0, 1) end
-- { nameplate x, y, indicator x, y }: parked off-screen, this skin has no entry nameplate
function EntryPlayer:nameplate_indicator_pos()
return { 0, 2000, 0, 2000 }
end
function EntryPlayer.new(side)
local self = setmetatable({}, EntryPlayer)
self.side = side
local katsu = side ~= 0
self.drum = tex.get_texture("entry/t14_entry/drum")
self.chara = tex.get_texture("entry/t14_entry/" .. (katsu and "katsu" or "don"))
self.fan = tex.get_texture("entry/t14_entry/" .. (katsu and "fan_katsu" or "fan_don"))
self.dx = katsu and 320 or 0
self.start_ms = nil
self.cloud_texture_change = tex.get_animation(7, "entry")
self.nameplate_fadein = tex.get_animation(12, "entry")
return self
end
function EntryPlayer:start_animations()
self.start_ms = tex.get_current_ms()
self.cloud_texture_change:start()
self.nameplate_fadein:start()
end
function EntryPlayer:update(current_ms)
self.cloud_texture_change:update(current_ms)
self.nameplate_fadein:update(current_ms)
end
function EntryPlayer:put(t, x, y, frame)
tex.draw_texture(t, { x = (x + self.dx) * K, y = y * K, frame = frame or 0 })
end
function EntryPlayer:draw_drum_back()
if not self.start_ms then return end
local e = (tex.get_current_ms() - self.start_ms) / FRAME_MS
if e >= 15 then
local y = e < 35 and lerp(364, 7, ease_out(seg(e, 15, 20))) or lerp(7, 31.8, ease_out(seg(e, 40, 4)))
if e >= 44 then y = 31.8 + 3.5 * math.sin(math.pi * 2 * (e - 44) / 60) end
local frame = e < 33 and 0 or e < 35 and 1 or e < 38 and 2 or e < 40 and 3 or 4
self:put(self.fan, 32, y, frame)
end
local drum_y = e < 22 and lerp(526, 236, ease_out(e / 22)) or lerp(236, 246, seg(e, 22, 3))
self:put(self.drum, 52, drum_y)
if e < 25 then
self:put(self.chara, 32, lerp(367.4, 47.4, ease_out(e / 25)), 0)
elseif e < 38 then
self:put(self.chara, 32, lerp(47.4, 87.4, ease_in(seg(e, 25, 13))), 1)
else
self:put(self.chara, 32, 87.4, e < 42 and 0 or 2)
end
end
function EntryPlayer:draw_drum_front() end
function EntryPlayer:is_cloud_finished()
return self.cloud_texture_change.is_finished
end
function EntryPlayer:get_nameplate_fade()
return self.nameplate_fadein.attribute
end