252 lines
9.6 KiB
Lua
252 lines
9.6 KiB
Lua
local DonBG4 = require("background/bg_objects/donbg/4")
|
|
local Fever = require("background/bg_objects/fever")
|
|
local Footer = require("background/bg_objects/footer")
|
|
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/gmt"
|
|
local MAX_DANCERS = 5
|
|
|
|
local GmtBGNormal = {}
|
|
GmtBGNormal.__index = GmtBGNormal
|
|
|
|
function GmtBGNormal.new()
|
|
local self = setmetatable({}, GmtBGNormal)
|
|
self.name = "bg_0"
|
|
tex.load_folder(COLLAB_PATH, "bg_normal/" .. self.name)
|
|
|
|
local bg_info = tex.get_texture_info(self.name, "background")
|
|
local bg_frames = (bg_info and bg_info.frame_count) or 1
|
|
local bg_textures = {}
|
|
for i = 0, bg_frames - 1 do
|
|
table.insert(bg_textures, { i * 400, (i + 1) * 400, i })
|
|
end
|
|
self.bg_flicker = anim.texture_change(bg_frames * 400, bg_textures, { loop = true })
|
|
self.bg_flicker:start()
|
|
|
|
local sparkle_info = tex.get_texture_info(self.name, "sparkle")
|
|
local sparkle_frames = (sparkle_info and sparkle_info.frame_count) or 1
|
|
local sparkle_textures = {}
|
|
for i = 0, sparkle_frames - 1 do
|
|
table.insert(sparkle_textures, { i * 60, (i + 1) * 60, i })
|
|
end
|
|
self.sparkle_anim = anim.texture_change(sparkle_frames * 60, sparkle_textures, { loop = true })
|
|
self.sparkle_anim:start()
|
|
|
|
self.kappa_anim = anim.texture_change(600, { { 0, 300, 0 }, { 300, 600, 1 } }, { loop = true })
|
|
self.kappa_anim:start()
|
|
|
|
self.hand_anim = anim.texture_change(800, { { 0, 500, 0 }, { 500, 800, 1 } }, { loop = true })
|
|
self.hand_anim:start()
|
|
|
|
self.totem_up = anim.move(450, { total_distance = 10, ease_out = "quadratic" })
|
|
self.totem_down = anim.move(450, { total_distance = 10, ease_in = "quadratic", delay = 450 })
|
|
self.totem_up:start()
|
|
self.totem_down:start()
|
|
self.body_up = anim.move(350, { total_distance = 8, ease_out = "quadratic" })
|
|
self.body_down = anim.move(350, { total_distance = 8, ease_in = "quadratic", delay = 350 })
|
|
self.body_up:start()
|
|
self.body_down:start()
|
|
|
|
self._id_bg = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "background") or 0
|
|
self._id_deco1 = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "deco1") or 0
|
|
self._id_deco2 = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "deco2") or 0
|
|
self._id_deco3 = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "deco3") or 0
|
|
self._id_deco4 = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "deco4") or 0
|
|
self._id_sparkle = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "sparkle") or 0
|
|
self._id_kappa = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "kappa") or 0
|
|
self._id_totem = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "totem") or 0
|
|
self._id_dancer2_body = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "dancer2_body") or 0
|
|
self._id_dancer2_hand = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "dancer2_hand") or 0
|
|
return self
|
|
end
|
|
|
|
function GmtBGNormal:update(current_time_ms)
|
|
self.bg_flicker:update(current_time_ms)
|
|
self.sparkle_anim:update(current_time_ms)
|
|
self.kappa_anim:update(current_time_ms)
|
|
self.hand_anim:update(current_time_ms)
|
|
self.totem_up:update(current_time_ms)
|
|
self.totem_down:update(current_time_ms)
|
|
if self.totem_down.is_finished then
|
|
self.totem_up:restart()
|
|
self.totem_down:restart()
|
|
end
|
|
self.body_up:update(current_time_ms)
|
|
self.body_down:update(current_time_ms)
|
|
if self.body_down.is_finished then
|
|
self.body_up:restart()
|
|
self.body_down:restart()
|
|
end
|
|
end
|
|
|
|
function GmtBGNormal:draw()
|
|
tex.draw_texture(self._id_bg, { frame = self.bg_flicker.attribute })
|
|
tex.draw_texture(self._id_deco1)
|
|
tex.draw_texture(self._id_deco2)
|
|
tex.draw_texture(self._id_deco3)
|
|
tex.draw_texture(self._id_deco4)
|
|
tex.draw_texture(self._id_sparkle, { frame = self.sparkle_anim.attribute })
|
|
tex.draw_texture(self._id_kappa, { frame = self.kappa_anim.attribute })
|
|
tex.draw_texture(self._id_totem, { y = -self.totem_up.attribute + self.totem_down.attribute })
|
|
tex.draw_texture(self._id_dancer2_body, { y = -self.body_up.attribute + self.body_down.attribute })
|
|
if self.hand_anim.attribute == 0 then
|
|
tex.draw_texture(self._id_dancer2_hand)
|
|
end
|
|
end
|
|
|
|
function GmtBGNormal:destroy() tex.unload_folder(COLLAB_PATH, "bg_normal/" .. self.name) end
|
|
|
|
local DonBG4Logo = setmetatable({}, { __index = DonBG4 })
|
|
DonBG4Logo.__index = DonBG4Logo
|
|
|
|
function DonBG4Logo.new(index, player_num, path)
|
|
local self = setmetatable({}, DonBG4Logo)
|
|
local base = DonBG4.new(index, player_num, path)
|
|
for k, v in pairs(base) do self[k] = v end
|
|
self.logo_texture = tex.get_texture_info(self.name, "logo")
|
|
self._id_logo = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "logo") or 0
|
|
return self
|
|
end
|
|
|
|
function DonBG4Logo:draw_textures(fade, y, frame)
|
|
DonBG4.draw_textures(self, fade, y, frame)
|
|
for i = 0, 4 do
|
|
tex.draw_texture(self._id_logo, {
|
|
fade = fade,
|
|
x = (i * self.logo_texture.width) + self.move.attribute,
|
|
y = y
|
|
})
|
|
end
|
|
end
|
|
|
|
local GmtBGFever = {}
|
|
GmtBGFever.__index = GmtBGFever
|
|
|
|
function GmtBGFever.new()
|
|
local self = setmetatable({}, GmtBGFever)
|
|
self.name = "bg_fever_0"
|
|
tex.load_folder(COLLAB_PATH, "bg_fever/" .. self.name)
|
|
self.transitioned = false
|
|
self.tomoe_spin = anim.move(6000, { total_distance = 360, loop = true })
|
|
self.tomoe_spin:start()
|
|
self.bg_texture = tex.get_texture_info(self.name, "background")
|
|
self._id_bg = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "background") or 0
|
|
self._id_tomoe = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "tomoe") or 0
|
|
self._id_logo = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "logo") or 0
|
|
return self
|
|
end
|
|
|
|
function GmtBGFever:start() end
|
|
|
|
function GmtBGFever:update(current_time_ms)
|
|
self.tomoe_spin:update(current_time_ms)
|
|
end
|
|
|
|
function GmtBGFever:draw()
|
|
local tw, th = self.bg_texture.width, self.bg_texture.height
|
|
for row = 0, math.ceil(720 / th) - 1 do
|
|
for col = 0, math.ceil(1280 / tw) - 1 do
|
|
tex.draw_texture(self._id_bg, { x = col * tw, y = row * th })
|
|
end
|
|
end
|
|
tex.draw_texture(self._id_tomoe, { rotation = self.tomoe_spin.attribute })
|
|
tex.draw_texture(self._id_logo)
|
|
end
|
|
|
|
function GmtBGFever:destroy() tex.unload_folder(COLLAB_PATH, "bg_fever/" .. self.name) end
|
|
|
|
-- Background
|
|
|
|
local GmtBackground = {}
|
|
GmtBackground.__index = GmtBackground
|
|
|
|
function GmtBackground.new(player_num, bpm)
|
|
local self = setmetatable({}, GmtBackground)
|
|
self.donbg = DonBG4Logo.new(1, player_num, COLLAB_PATH)
|
|
self.bg_normal = GmtBGNormal.new()
|
|
self.bg_fever = GmtBGFever.new()
|
|
self.footer = Footer.new(COLLAB_PATH, -1)
|
|
self.fever = Fever.create(math.random(0, 3), bpm, "background")
|
|
self.dancer = Dancer.create(math.random(0, 20), bpm, "background", MAX_DANCERS)
|
|
self.renda = RendaController.new("background", math.random(0, 2))
|
|
self.chibi = ChibiController.new(bpm, "background")
|
|
self.is_clear = false
|
|
self.is_rainbow = false
|
|
self.last_milestone = 1
|
|
|
|
return self
|
|
end
|
|
|
|
function GmtBackground:update(current_ms, bpm)
|
|
self.donbg:update(current_ms, bpm)
|
|
self.bg_fever: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 GmtBackground:handle_good(player_num) self.chibi:add_chibi(player_num, false) end
|
|
|
|
function GmtBackground:handle_ok(player_num) self.chibi:add_chibi(player_num, false) end
|
|
|
|
function GmtBackground:handle_bad(player_num) self.chibi:add_chibi(player_num, true) end
|
|
|
|
function GmtBackground:handle_drumroll(player_num) self.renda:add_renda() end
|
|
|
|
function GmtBackground:handle_balloon(player_num) self.renda:add_renda() end
|
|
|
|
function GmtBackground:handle_gauge(player_num, progress, is_clear, is_rainbow)
|
|
self.donbg:set_clear(is_clear)
|
|
if is_clear and not self.is_clear then self.bg_fever:start() end
|
|
if is_rainbow and not self.is_rainbow then self.fever:start() end
|
|
if not is_rainbow and self.is_rainbow then self.fever:stop() 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 GmtBackground:draw_back()
|
|
if self.is_clear then
|
|
self.bg_fever:draw()
|
|
else
|
|
self.bg_normal:draw()
|
|
end
|
|
self.donbg:draw()
|
|
self.renda:draw()
|
|
self.dancer:draw()
|
|
self.footer:draw()
|
|
self.fever:draw()
|
|
self.chibi:draw()
|
|
end
|
|
|
|
function GmtBackground:draw_fore() end
|
|
|
|
function GmtBackground: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()
|
|
end
|
|
|
|
return GmtBackground
|