local DonBGBase = require("background/bg_objects/donbg/base") 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 -- set per-variant in create() local MAX_DANCERS -- set per-variant in create() -- Spotlight colors: {r,g,b,a} local SPOTLIGHT_COLORS = { { 0, 255, 255, 255 }, -- cyan { 255, 255, 0, 255 }, -- yellow { 255, 0, 255, 255 }, -- magenta { 0, 255, 255, 255 }, -- cyan { 255, 255, 0, 255 }, -- yellow } -- BGNormal: flicker fade + 5 alternating spotlights local ImasBGNormal = {} ImasBGNormal.__index = ImasBGNormal function ImasBGNormal.new(path) local self = setmetatable({}, ImasBGNormal) self.name = "bg_0" self.path = path tex.load_folder(path, "bg_normal/" .. self.name) self.overlay_fade = anim.fade(1000, { initial_opacity = 0.0, final_opacity = 1.0, reverse_delay = 500, delay = 500, loop = true }) self._id_bg = tex.get_texture(self.path .. "/" .. self.name .. "/" .. "background") or 0 self._id_overlay = tex.get_texture(self.path .. "/" .. self.name .. "/" .. "overlay") or 0 self._id_spotlight = tex.get_texture(self.path .. "/" .. self.name .. "/" .. "spotlight") or 0 return self end function ImasBGNormal:update(current_time_ms) self.overlay_fade:update(current_time_ms) end function ImasBGNormal:draw() local ov = self.overlay_fade.attribute tex.draw_texture(self._id_bg) tex.draw_texture(self._id_overlay, { fade = ov }) for i = 0, 4 do local fade = (i % 2 == 0) and math.min(0.5, ov) or math.min(0.5, 1 - ov) tex.draw_texture(self._id_spotlight, { index = i, color = SPOTLIGHT_COLORS[i + 1], fade = fade }) end end function ImasBGNormal:destroy() tex.unload_folder(self.path, "bg_normal/" .. self.name) end -- BGFever: same flicker fade + spotlights + orange/green lights local ImasBGFever = {} ImasBGFever.__index = ImasBGFever function ImasBGFever.new(path) local self = setmetatable({}, ImasBGFever) self.name = "bg_fever_0" self.path = path tex.load_folder(path, "bg_fever/" .. self.name) self.transitioned = false self.overlay_fade = anim.fade(1000, { initial_opacity = 0.0, final_opacity = 1.0, reverse_delay = 500, delay = 500, loop = true }) self._id_bg = tex.get_texture(self.path .. "/" .. self.name .. "/" .. "background") or 0 self._id_overlay = tex.get_texture(self.path .. "/" .. self.name .. "/" .. "overlay") or 0 self._id_light_orange = tex.get_texture(self.path .. "/" .. self.name .. "/" .. "light_orange") or 0 self._id_light_green = tex.get_texture(self.path .. "/" .. self.name .. "/" .. "light_green") or 0 self._id_spotlight = tex.get_texture(self.path .. "/" .. self.name .. "/" .. "spotlight") or 0 return self end function ImasBGFever:start() self.transitioned = true end function ImasBGFever:update(current_time_ms) self.overlay_fade:update(current_time_ms) end function ImasBGFever:draw() local ov = self.overlay_fade.attribute tex.draw_texture(self._id_bg) tex.draw_texture(self._id_overlay, { fade = ov }) tex.draw_texture(self._id_light_orange, { fade = ov }) tex.draw_texture(self._id_light_green, { fade = 1 - ov }) for i = 0, 4 do local fade = (i % 2 == 0) and math.min(0.5, ov) or math.min(0.5, 1 - ov) tex.draw_texture(self._id_spotlight, { index = i, color = SPOTLIGHT_COLORS[i + 1], fade = fade }) end end function ImasBGFever:destroy() tex.unload_folder(self.path, "bg_fever/" .. self.name) end -- Fever: BaseFever + 2-frame texture_change overlay (2-beat cycle) local ImasFever = {} ImasFever.__index = ImasFever function ImasFever.new(bpm, path) local self = setmetatable({}, ImasFever) local base = Fever.Base.new(0, bpm, path) for k, v in pairs(base) do self[k] = v end local total = 120000 / bpm self.texture_change = anim.texture_change(total, { { 0, total / 2, 0 }, { total / 2, total, 1 } }, { loop = true }) return self end function ImasFever:start() Fever.Base.start(self) end function ImasFever:update(current_time_ms, bpm) Fever.Base.update(self, current_time_ms, bpm) self.texture_change:update(current_time_ms) end function ImasFever:draw() local y = self.bounce_down.attribute - self.bounce_up.attribute tex.draw_texture(self._id_overlay, { y = y, frame = self.texture_change.attribute }) end -- Background factory (used for IMAS, IMAS_CG, IMAS_ML) local ImasBackground = {} ImasBackground.__index = ImasBackground function ImasBackground.new(player_num, bpm, path, max_dancers) local self = setmetatable({}, ImasBackground) self.donbg = DonBGBase.new(1, player_num, path) self.bg_normal = ImasBGNormal.new(path) self.bg_fever = ImasBGFever.new(path) self.footer = Footer.new(path, 0) self.fever = ImasFever.new(bpm, path) self.dancer = Dancer.BaseDancerGroup.new(0, bpm, max_dancers, path) self.renda = RendaController.new(path, 0) self.chibi = ChibiController.new(bpm, path, 0) self.max_dancers = max_dancers self.is_clear = false self.is_rainbow = false self.last_milestone = 1 return self end function ImasBackground:update(current_ms, bpm) self.donbg:update(current_ms) self.bg_normal:update(current_ms) 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 ImasBackground:handle_good(player_num) self.chibi:add_chibi(player_num, false) end function ImasBackground:handle_ok(player_num) self.chibi:add_chibi(player_num, false) end function ImasBackground:handle_bad(player_num) self.chibi:add_chibi(player_num, true) end function ImasBackground:handle_drumroll(player_num) self.renda:add_renda() end function ImasBackground:handle_balloon(player_num) self.renda:add_renda() end function ImasBackground: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 self.is_clear = is_clear self.is_rainbow = is_rainbow local md = self.max_dancers local current_milestone if is_clear then current_milestone = md else current_milestone = math.min(md - 1, math.floor(progress * md)) 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 ImasBackground:draw_back() if self.is_clear then if not self.bg_fever.transitioned then self.bg_normal:draw() self.bg_fever:draw() else self.bg_fever:draw() end else self.bg_normal:draw() end 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 ImasBackground:draw_fore() end function ImasBackground: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 -- Export the factory and the ImasFever class (reused by imas_sidem) local Imas = {} Imas.new = ImasBackground.new Imas.ImasFever = ImasFever -- Callable as a collab constructor: Imas.new(player_num, bpm, path, max_dancers) setmetatable(Imas, { __call = function(_, player_num, bpm, path, max_dancers) return ImasBackground.new(player_num, bpm, path, max_dancers) end }) return Imas