Files
PyTaikoGreen/Scripts/background/bg_collabs/momoclo.lua
T
2026-09-20 13:37:46 -04:00

198 lines
6.8 KiB
Lua

local DonBG4 = require("background/bg_objects/donbg/4")
local Fever = require("background/bg_objects/fever")
local Dancer = require("background/bg_objects/dancer")
local RendaController = require("background/bg_objects/renda")
local ChibiController = require("background/bg_objects/chibi")
local COLLAB_PATH = "background/collab/momoclo"
local MAX_DANCERS = 5
local MomocloDonBG = setmetatable({}, { __index = DonBG4 })
MomocloDonBG.__index = MomocloDonBG
function MomocloDonBG.new(index, player_num, path)
local self = setmetatable({}, MomocloDonBG)
local base = DonBG4.new(index, player_num, path)
for k, v in pairs(base) do self[k] = v end
return self
end
function MomocloDonBG:draw_textures(fade, y, frame)
for i = 0, 4 do
tex.draw_texture(self._id_bg, {
frame = frame,
fade = fade,
x = (i * self.bg_texture.width) + self.move.attribute,
y = y
})
end
for i = 0, 7 do
tex.draw_texture(self._id_overlay, {
frame = frame,
fade = fade,
x = (i * self.overlay_texture.width) + self.move.attribute,
y = self.overlay_move.attribute + y
})
end
end
local MomocloFooter = {}
MomocloFooter.__index = MomocloFooter
local FOOTER_X = { 160, 480, 800, 1120 }
local FOOTER_MIRROR = { true, true, false, false }
local FOOTER_Y = 360
function MomocloFooter.new()
local self = setmetatable({}, MomocloFooter)
tex.load_folder(COLLAB_PATH, "footer")
self.light_texture = tex.get_texture_info("footer", "light")
self.glow_texture = tex.get_texture_info("footer", "glow")
self._id_light = tex.get_texture(COLLAB_PATH .. "/" .. "footer" .. "/" .. "light") or 0
self._id_glow = tex.get_texture(COLLAB_PATH .. "/" .. "footer" .. "/" .. "glow") or 0
return self
end
function MomocloFooter:draw()
for i, x in ipairs(FOOTER_X) do
tex.draw_texture(self._id_glow, {
x = x - self.glow_texture.width / 2,
y = FOOTER_Y + self.light_texture.height - self.glow_texture.height / 2,
blend = "additive"
})
tex.draw_texture(self._id_light, {
x = x - self.light_texture.width / 2,
y = FOOTER_Y,
mirror = FOOTER_MIRROR[i] and "horizontal" or nil
})
end
end
function MomocloFooter:destroy() tex.unload_folder(COLLAB_PATH, "footer") end
local MomocloBG = {}
MomocloBG.__index = MomocloBG
function MomocloBG.new(folder, name, has_glow)
local self = setmetatable({}, MomocloBG)
self.folder = folder
self.name = name
tex.load_folder(COLLAB_PATH, folder .. "/" .. name)
self._id_beam = tex.get_texture(COLLAB_PATH .. "/" .. name .. "/" .. "beam") or 0
self._id_truss = tex.get_texture(COLLAB_PATH .. "/" .. name .. "/" .. "truss") or 0
self._id_tower = tex.get_texture(COLLAB_PATH .. "/" .. name .. "/" .. "tower") or 0
self._id_floor = tex.get_texture(COLLAB_PATH .. "/" .. name .. "/" .. "floor") or 0
self._id_glow = has_glow and (tex.get_texture(COLLAB_PATH .. "/" .. name .. "/" .. "glow") or 0) or nil
return self
end
function MomocloBG:start() end
function MomocloBG:update(current_time_ms) end
function MomocloBG:draw()
tex.draw_texture(self._id_beam)
tex.draw_texture(self._id_truss)
tex.draw_texture(self._id_tower)
tex.draw_texture(self._id_floor)
if self._id_glow then tex.draw_texture(self._id_glow) end
end
function MomocloBG:destroy() tex.unload_folder(COLLAB_PATH, self.folder .. "/" .. self.name) end
-- Background
local MomocloBackground = {}
MomocloBackground.__index = MomocloBackground
function MomocloBackground.new(player_num, bpm)
local self = setmetatable({}, MomocloBackground)
self.donbg = MomocloDonBG.new(1, player_num, COLLAB_PATH)
self.bg_normal = MomocloBG.new("bg_normal", "bg_0", false)
self.bg_fever = MomocloBG.new("bg_fever", "bg_fever_0", true)
self.footer = MomocloFooter.new()
self.fever = Fever.create(0, bpm, COLLAB_PATH)
self.dancer = Dancer.BaseDancerGroup.new(0, bpm, MAX_DANCERS, COLLAB_PATH)
self.renda = RendaController.new(COLLAB_PATH, 0)
self.chibi = ChibiController.new(bpm, COLLAB_PATH, 1)
self.is_clear = false
self.is_rainbow = false
self.last_milestone = 1
tex.load_folder(COLLAB_PATH, "dodai")
self._id_dodai_0 = tex.get_texture(COLLAB_PATH .. "/" .. "dodai" .. "/" .. "dodai_0") or 0
self._id_dodai_1 = tex.get_texture(COLLAB_PATH .. "/" .. "dodai" .. "/" .. "dodai_1") or 0
return self
end
function MomocloBackground:update(current_ms, bpm)
self.donbg:update(current_ms)
self.fever:update(current_ms, bpm)
self.dancer:update(current_ms, bpm)
self.renda:update(current_ms)
self.chibi:update(current_ms, bpm)
end
function MomocloBackground:handle_good(player_num) self.chibi:add_chibi(player_num, false) end
function MomocloBackground:handle_ok(player_num) self.chibi:add_chibi(player_num, false) end
function MomocloBackground:handle_bad(player_num) self.chibi:add_chibi(player_num, true) end
function MomocloBackground:handle_drumroll(player_num) self.renda:add_renda() end
function MomocloBackground:handle_balloon(player_num) self.renda:add_renda() end
function MomocloBackground:handle_gauge(player_num, progress, is_clear, is_rainbow)
self.donbg:set_clear(is_clear)
if is_rainbow and not self.is_rainbow then self.fever:start() end
self.is_clear = is_clear
self.is_rainbow = is_rainbow
local current_milestone
if is_clear then
current_milestone = MAX_DANCERS
else
current_milestone = math.min(MAX_DANCERS - 1, math.floor(progress * MAX_DANCERS))
end
if current_milestone > self.last_milestone then
for _ = 1, current_milestone - self.last_milestone do self.dancer:add_dancer() end
self.last_milestone = current_milestone
elseif current_milestone < self.last_milestone then
for _ = 1, self.last_milestone - current_milestone do self.dancer:remove_dancer() end
self.last_milestone = current_milestone
end
end
function MomocloBackground:draw_back()
if self.is_clear then
self.bg_fever:draw()
else
self.bg_normal:draw()
end
tex.draw_texture(self._id_dodai_0)
tex.draw_texture(self._id_dodai_1)
self.donbg:draw()
self.renda:draw()
self.dancer:draw()
self.footer:draw()
if self.is_rainbow then self.fever:draw() end
self.chibi:draw()
end
function MomocloBackground:draw_fore() end
function MomocloBackground:destroy()
self.donbg:destroy()
self.bg_normal:destroy()
self.bg_fever:destroy()
self.fever:destroy()
self.dancer:destroy()
self.footer:destroy()
self.renda:destroy()
self.chibi:destroy()
tex.unload_folder(COLLAB_PATH, "dodai")
end
return MomocloBackground