180 lines
6.7 KiB
Lua
180 lines
6.7 KiB
Lua
local DonBG4 = require("background/bg_objects/donbg/4")
|
|
local BGNormal = require("background/bg_objects/bg_normal")
|
|
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/gb"
|
|
local MAX_DANCERS = 5
|
|
|
|
local GbBGFever = {}
|
|
GbBGFever.__index = GbBGFever
|
|
|
|
function GbBGFever.new()
|
|
local self = setmetatable({}, GbBGFever)
|
|
self.name = "bg_fever_0"
|
|
tex.load_folder(COLLAB_PATH, "bg_fever/" .. self.name)
|
|
self.transitioned = false
|
|
|
|
local bg_info = tex.get_texture_info(self.name, "background")
|
|
local bg_frames = (bg_info and bg_info.frame_count) or 1
|
|
local kin_info = tex.get_texture_info(self.name, "kin")
|
|
local kin_frames = (kin_info and kin_info.frame_count) or 1
|
|
local baku_info = tex.get_texture_info(self.name, "baku")
|
|
local baku_frames = (baku_info and baku_info.frame_count) or 1
|
|
|
|
local bg_textures = {}
|
|
for i = 0, bg_frames - 1 do
|
|
table.insert(bg_textures, { i * 150, (i + 1) * 150, i })
|
|
end
|
|
self.bg_flicker = anim.texture_change(bg_frames * 150, bg_textures, { loop = true })
|
|
self.bg_flicker:start()
|
|
|
|
local kin_textures = {}
|
|
for i = 0, kin_frames - 1 do
|
|
table.insert(kin_textures, { i * 120, (i + 1) * 120, i })
|
|
end
|
|
self.kin_flicker = anim.texture_change(kin_frames * 120, kin_textures, { loop = true })
|
|
self.kin_flicker:start()
|
|
|
|
local baku_textures = {}
|
|
for i = 0, baku_frames - 1 do
|
|
table.insert(baku_textures, { i * 120, (i + 1) * 120, i })
|
|
end
|
|
self.baku_flicker = anim.texture_change(baku_frames * 120, baku_textures, { loop = true, delay = 60 })
|
|
self.baku_flicker:start()
|
|
|
|
self.screen_width = tex.get_screen_width()
|
|
self.ray_spin = anim.move(4000, { total_distance = 360, loop = true })
|
|
self.ray_spin:start()
|
|
|
|
self._id_bg = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "background") or 0
|
|
self._id_footer = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "footer") or 0
|
|
self._id_kin = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "kin") or 0
|
|
self._id_baku = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "baku") or 0
|
|
self._id_ray_gold = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "ray_gold") or 0
|
|
self._id_ray_cyan = tex.get_texture(COLLAB_PATH .. "/" .. self.name .. "/" .. "ray_cyan") or 0
|
|
|
|
return self
|
|
end
|
|
|
|
function GbBGFever:start() end
|
|
|
|
function GbBGFever:update(current_time_ms)
|
|
self.bg_flicker:update(current_time_ms)
|
|
self.kin_flicker:update(current_time_ms)
|
|
self.baku_flicker:update(current_time_ms)
|
|
self.ray_spin:update(current_time_ms)
|
|
end
|
|
|
|
function GbBGFever:draw()
|
|
tex.draw_texture(self._id_bg, { frame = self.bg_flicker.attribute })
|
|
tex.draw_texture(self._id_bg, { frame = self.bg_flicker.attribute, mirror = "horizontal", x = self.screen_width })
|
|
tex.draw_texture(self._id_ray_gold, { rotation = self.ray_spin.attribute })
|
|
tex.draw_texture(self._id_ray_cyan, { rotation = -self.ray_spin.attribute })
|
|
tex.draw_texture(self._id_footer)
|
|
tex.draw_texture(self._id_kin, { frame = self.kin_flicker.attribute })
|
|
tex.draw_texture(self._id_baku, { frame = self.baku_flicker.attribute })
|
|
end
|
|
|
|
function GbBGFever:destroy() tex.unload_folder(COLLAB_PATH, "bg_fever/" .. self.name) end
|
|
|
|
-- Background
|
|
|
|
local GbBackground = {}
|
|
GbBackground.__index = GbBackground
|
|
|
|
function GbBackground.new(player_num, bpm)
|
|
local self = setmetatable({}, GbBackground)
|
|
self.donbg = DonBG4.new(1, player_num, COLLAB_PATH)
|
|
self.bg_normal = BGNormal.Base.new(0, COLLAB_PATH)
|
|
self.bg_fever = GbBGFever.new()
|
|
self.footer = Footer.new(COLLAB_PATH, -1)
|
|
self.fever = Fever.create(0, bpm, COLLAB_PATH)
|
|
self.dancer = Dancer.BaseDancerGroup.new(0, bpm, MAX_DANCERS, COLLAB_PATH)
|
|
for i, d in ipairs(self.dancer.dancers) do
|
|
if d.index == 4 then
|
|
self.dancer.dancers[i], self.dancer.dancers[1] = self.dancer.dancers[1], self.dancer.dancers[i]
|
|
break
|
|
end
|
|
end
|
|
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
|
|
return self
|
|
end
|
|
|
|
function GbBackground: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 GbBackground:handle_good(player_num) self.chibi:add_chibi(player_num, false) end
|
|
|
|
function GbBackground:handle_ok(player_num) self.chibi:add_chibi(player_num, false) end
|
|
|
|
function GbBackground:handle_bad(player_num) self.chibi:add_chibi(player_num, true) end
|
|
|
|
function GbBackground:handle_drumroll(player_num) self.renda:add_renda() end
|
|
|
|
function GbBackground:handle_balloon(player_num) self.renda:add_renda() end
|
|
|
|
function GbBackground: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 GbBackground:draw_back()
|
|
self.bg_normal:draw()
|
|
if self.is_clear then
|
|
self.bg_fever:draw()
|
|
end
|
|
self.donbg:draw()
|
|
self.renda:draw()
|
|
self.dancer:draw()
|
|
self.footer:draw()
|
|
self.fever:draw()
|
|
self.chibi:draw()
|
|
end
|
|
|
|
function GbBackground:draw_fore() end
|
|
|
|
function GbBackground: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 GbBackground
|