81 lines
3.2 KiB
Lua
81 lines
3.2 KiB
Lua
-- YataiDONJuuyon entry player: the drum and character of juu-yon's main menu
|
|
-- (scenes/main_menu.tscn P1Anims, animation "Enter"):
|
|
-- TaikoP1 (entry/taiko.png 325x373) position keys 0 s (24,640) 0.3 s (24,384) 0.4 s (24,384)
|
|
-- 0.6 s (24,416) 0.8 s (24,400)
|
|
-- TaikoCharaP1 (384x384 frame) position keys 0 s (0,-384) 0.4 s (0,144) 0.6 s (0,160)
|
|
-- 0.8 s (0,144)
|
|
-- (interpolated linearly between keys). The character is juu-yon's own 2D Don
|
|
-- (assets/game/chara/default: Graphics/entry/jy_entry/chara frames 0-7 = idle.png, 8-9 = misc.png),
|
|
-- not the engine's 3D model (no costumes): draw_drum_back returns nothing, so the engine skips it.
|
|
-- "Enter" state/frame keys: 0 s misc 0 (airborne), 0.4 s idle 7, 0.8 s idle animating -- chara.gd:
|
|
-- idle 8 frames at speed 0.25 = a frame every half beat, TaikoCharaP1.bpm 118.
|
|
-- juu-yon shows no join cloud: the engine's cloud animation still runs (the mode boards wait for
|
|
-- it) but is not drawn. The 2P drum, which juu-yon's main menu does not have, sits 480 px right.
|
|
EntryPlayer = {}
|
|
EntryPlayer.__index = EntryPlayer
|
|
|
|
local DRUM_KEYS = { { 0, 640 }, { 300, 384 }, { 400, 384 }, { 600, 416 }, { 800, 400 } }
|
|
local CHARA_KEYS = { { 0, -384 }, { 400, 144 }, { 600, 160 }, { 800, 144 } }
|
|
|
|
local function key_at(keys, t)
|
|
if t <= keys[1][1] then return keys[1][2] end
|
|
for i = 2, #keys do
|
|
if t <= keys[i][1] then
|
|
local a, b = keys[i - 1], keys[i]
|
|
return a[2] + (b[2] - a[2]) * (t - a[1]) / (b[1] - a[1])
|
|
end
|
|
end
|
|
return keys[#keys][2]
|
|
end
|
|
|
|
local CHARA_BPM, CHARA_MISC = 118, 8
|
|
|
|
-- { 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
|
|
self.drum = tex.get_texture("entry/jy_entry/taiko")
|
|
self.chara = tex.get_texture("entry/jy_entry/chara")
|
|
self.x0 = (side == 0) and 24 or 504
|
|
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:draw_drum_back()
|
|
local t = self.start_ms and (tex.get_current_ms() - self.start_ms) or 0
|
|
local dy = key_at(DRUM_KEYS, t)
|
|
tex.draw_texture(self.drum, { x = self.x0, y = dy })
|
|
local frame
|
|
if t < 400 then frame = CHARA_MISC
|
|
elseif t < 800 then frame = 7
|
|
else frame = math.floor((t - 800) / 1000 * CHARA_BPM / 60 * 2) % 8 end
|
|
tex.draw_texture(self.chara, { x = self.x0 - 24, y = key_at(CHARA_KEYS, t), frame = frame })
|
|
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
|