117 lines
4.1 KiB
Lua
117 lines
4.1 KiB
Lua
local DonBGBase = require("background/bg_objects/donbg/base")
|
|
local BGNormal = require("background/bg_objects/bg_normal")
|
|
local Footer = require("background/bg_objects/footer")
|
|
local ChibiController = require("background/bg_objects/chibi")
|
|
local BaseChibi = require("background/bg_objects/chibi/base")
|
|
local ChibiWave = require("background/bg_objects/chibi/wave")
|
|
local Timing = require("background/bg_objects/timing")
|
|
local chain_moves, sum, Loop = Timing.chain_moves, Timing.sum, Timing.Loop
|
|
|
|
local COLLAB_PATH = "background/collab/dan"
|
|
|
|
-- Don band: the dojo has one look for every state (no clear set). Ambient, in ms.
|
|
local STREAK = { ms = 2000, dx = -620, dy = 330, tile = 0 } -- the same streak twice, one pass apart
|
|
local DONBG = {
|
|
layers = {
|
|
{ key = "background", tile = 0 },
|
|
{ key = "bg_overlay", x = -56 },
|
|
{ key = "bg_overlay_2", x = 260, ms = 5333, alpha = 0.8 },
|
|
{ key = "bg_overlay_3", x = 800, y = 30, tile = 0 },
|
|
setmetatable({ key = "overlay_1", x = 1144, y = -140 }, { __index = STREAK }),
|
|
setmetatable({ key = "overlay_1", x = 524, y = -140 }, { __index = STREAK }),
|
|
-- crests slide left one tile every 5.3s, swaying up 20px and back every 2s
|
|
{
|
|
key = "overlay_2", x = -14, y = -12, tile = 320, ms = 5333, dx = -320,
|
|
period = 2000,
|
|
bob = { { 500, -10, "in" }, { 500, -10, "out" }, { 500, 10, "in" }, { 500, 10, "out" } },
|
|
},
|
|
},
|
|
}
|
|
|
|
-- Chibi: a disc that hops in and rolls along bobbing, its swirl turning once a beat
|
|
local DISC = {
|
|
key = "0",
|
|
hop = { from = { -419, 22 }, peak = { -325, -33 }, up = 0.3 },
|
|
run = { y = 1 },
|
|
wave = { first = 10, height = 30, beats = 0.5 },
|
|
}
|
|
|
|
local ChibiDisc = setmetatable({}, { __index = ChibiWave })
|
|
ChibiDisc.__index = ChibiDisc
|
|
|
|
function ChibiDisc.new(spec, path, folder, bpm, is_2p)
|
|
local self = setmetatable({}, ChibiDisc)
|
|
self:init(spec, path, folder, bpm, is_2p)
|
|
return self
|
|
end
|
|
|
|
function ChibiDisc:update_extra(current_time_ms)
|
|
ChibiWave.update_extra(self, current_time_ms)
|
|
if self.hopping then return end
|
|
self.spin = self.spin or Loop.new(self.beat, function()
|
|
return { rot = chain_moves({ { 1, 360 } }, self.beat, 1) }
|
|
end)
|
|
self.spin:update(current_time_ms)
|
|
end
|
|
|
|
function ChibiDisc:draw()
|
|
if not self.t0 then return end
|
|
local at = self:place()
|
|
self:draw_image(at)
|
|
local swirl = self._swirl or {}
|
|
self._swirl = swirl
|
|
swirl.x, swirl.y, swirl.sx, swirl.sy, swirl.frame = at.x, at.y, at.sx, at.sy, 0
|
|
swirl.rot = self.spin and self.spin.anims and sum(self.spin.anims.rot) or 0
|
|
swirl.fade = self.hopping and self.t / 0.5 or nil -- fades in over the hop
|
|
self:draw_image(swirl, "1")
|
|
end
|
|
|
|
-- Background
|
|
|
|
local DanBackground = {}
|
|
DanBackground.__index = DanBackground
|
|
|
|
function DanBackground.new(player_num, bpm)
|
|
local self = setmetatable({}, DanBackground)
|
|
self.donbg = DonBGBase.new(1, player_num, COLLAB_PATH, DONBG)
|
|
self.bg_normal = BGNormal.Base.new(0, COLLAB_PATH)
|
|
self.footer = Footer.new(COLLAB_PATH, 0)
|
|
self.chibi = ChibiController.new(bpm, COLLAB_PATH, 1)
|
|
return self
|
|
end
|
|
|
|
function DanBackground:update(current_ms, bpm)
|
|
self.donbg:update(current_ms, bpm)
|
|
self.chibi:update(current_ms, bpm)
|
|
end
|
|
|
|
function DanBackground:handle_good(player_num) BaseChibi.add(self.chibi, DISC, COLLAB_PATH, player_num, ChibiDisc) end
|
|
|
|
function DanBackground:handle_ok(player_num) BaseChibi.add(self.chibi, DISC, COLLAB_PATH, player_num, ChibiDisc) end
|
|
|
|
function DanBackground:handle_bad(player_num) self.chibi:add_chibi(player_num, true) end
|
|
|
|
function DanBackground:handle_drumroll(player_num) end
|
|
|
|
function DanBackground:handle_balloon(player_num) end
|
|
|
|
function DanBackground:handle_gauge(player_num, progress, is_clear, is_rainbow) end
|
|
|
|
function DanBackground:draw_back()
|
|
self.bg_normal:draw()
|
|
self.donbg:draw()
|
|
self.footer:draw()
|
|
self.chibi:draw()
|
|
end
|
|
|
|
function DanBackground:draw_fore() end
|
|
|
|
function DanBackground:destroy()
|
|
self.donbg:destroy()
|
|
self.bg_normal:destroy()
|
|
self.footer:destroy()
|
|
self.chibi:destroy()
|
|
end
|
|
|
|
return DanBackground
|