local TRACKS = require("background/bg_data/tutorial_ac") local L = TRACKS.layers local FOLDER = "tutorial_ac" local PATH = "background/" .. FOLDER local FRAME_MS = 1000.0 / 60.0 local BAND_TOP = 60 local CLOUD_X0, CLOUD_PITCH, CLOUD_COUNT = 600, 744, 5 -- the clouds' places inside their strip local CLOUD_Y0 = 30 -- the cloud's own offset in its exported frame TutorialBackground = {} TutorialBackground.__index = TutorialBackground function TutorialBackground.new(player_num, bpm) local self = setmetatable({}, TutorialBackground) tex.load_folder("background", FOLDER) self.id = {} for _, name in ipairs({ "pat", "mtn", "cloud", "w13", "w16", "w21", "w24", "floor" }) do self.id[name] = tex.get_texture(PATH .. "/" .. name) or 0 end self.t0 = nil self.f = 0 return self end function TutorialBackground:update(current_ms, bpm) if not self.t0 then self.t0 = current_ms end self.f = math.max(0, math.floor((current_ms - self.t0) / FRAME_MS)) end local function at(track, list, f, n) return track[list][(f % n) + 1] end -- whole pixels: drawn between pixels, the filtered layers came out soft local function px(v) return math.floor(v + 0.5) end -- a strip whose x / y follow its track; rows above the top band are cut off function TutorialBackground:strip(name, track_name, f) local tr = TRACKS[track_name] local x = px(at(tr, "x", f, tr.n)) local y = name == "pat" and 0 or (name == "mtn" and 0 or at(tr, "y", f, 120)) local top = px(y + L[name].ytop) local cut = math.max(0, BAND_TOP - top) tex.draw_texture(self.id[name], { x = x, y = top + cut, y2 = -cut, src = { x = 0, y = cut, width = L[name].w, height = L[name].h - cut }, }) end function TutorialBackground:handle_good(player_num) end function TutorialBackground:handle_ok(player_num) end function TutorialBackground:handle_bad(player_num) end function TutorialBackground:handle_drumroll(player_num) end function TutorialBackground:handle_balloon(player_num) end function TutorialBackground:handle_gauge(player_num, progress, is_clear, is_rainbow) end function TutorialBackground:draw_back() local f = self.f tex.draw_texture(self.id.floor, { y = L.floor.y }) self:strip("pat", "pat", f) self:strip("mtn", "mtn", f) local cx = at(TRACKS.cloud, "x", f, TRACKS.cloud.n) local cy = at(TRACKS.c9, "y", f, 120) - CLOUD_Y0 for k = 0, CLOUD_COUNT - 1 do tex.draw_texture(self.id.cloud, { x = px(cx + CLOUD_X0 + CLOUD_PITCH * k + L.cloud.dx), y = px(cy + L.cloud.dy) }) end self:strip("w13", "w13", f) self:strip("w16", "w16", f) self:strip("w21", "w21", f) self:strip("w24", "w24", f) end function TutorialBackground:draw_fore() end function TutorialBackground:destroy() tex.unload_folder("background", FOLDER) end return TutorialBackground