FCAnimation = {} FCAnimation.__index = FCAnimation -- Taiko 14 full combo (enso/1PDON/fullcombo1) on the lane: a scroll slides in from the right and bounces to a stop -- at the drum, its banner unrolls out of the roller with フルコンボ!!, flowers pop along it in pairs and the text -- flashes white. Positions are 640x480 swg px from the lane part (104, 109), x K; frames are swg frames (60 fps). local K = tex.get_screen_width() / 640 local FRAME_MS = 1000 / 60 local PART_X, PART_Y = 104 * K + 6, 109 * K - 138 + 2 -- from the lane's y (as Graphics/game/lane) local SCROLL_Y, ROLLER_X, ROLLER_Y = -5, 50, -4.6 local UNROLL_AT, UNROLL_END, BANNER_FROM, BANNER_TO, BANNER_Y = 77, 108, -234.7, 98.3, 3 local CLIP_X = 114 -- the banner shows right of the roller's axle local TEXT_DX, TEXT_DY = 40, 15.4 -- scroll x after it stops accelerating: a few hand-picked bounces local BOUNCE = { { 56, 99.6 }, { 60, 56.1 }, { 64, 69.4 }, { 68, 58.8 }, { 72, 59.4 }, { 76, 50 } } -- flowers: rest top-left, in pairs every 4 frames from frame 112 (lower ones pop from 1.28, upper from 1.13) local FLOWERS = { { 84.7, 37.3 }, { 109.7, -31.7 }, { 167.3, 30.4 }, { 212.3, -33.7 }, { 254.3, 36.3 }, { 301.3, -35.7 }, { 342.3, 38.3 }, { 389.3, -25.6 } } local FLOWERS_AT, FLASH_AT, VOICE_AT = 112, 124, 77 function FCAnimation.new(is_2p, donderful, two_player) local self = setmetatable({}, FCAnimation) self.lane_y = is_2p and tex.get_skin_config("game_p2_y").y or 184 * tex.get_screen_scale() local function t(name) local id = tex.get_texture("game/ending_anim/" .. name) local info = tex.get_texture_info("ending_anim", name) return id and info and { id = id, w = info.width, h = info.height } or nil end self.scroll, self.roller, self.banner = t("fc_scroll"), t("fc_roller"), t("fc_banner") self.text, self.text_white = t("fc_text"), t("fc_text_white") self.flowers = {} for i = 1, #FLOWERS do self.flowers[i] = t("fc_flower_" .. i) end self.combo_sound = donderful and audio.has_sound("donderful_combo") and "donderful_combo" or "full_combo" local side_voice = "full_combo_voice_" .. (is_2p and "2p" or "1p") if donderful and audio.has_sound("donderful_combo_voice") then self.combo_voice = "donderful_combo_voice" elseif two_player and audio.has_sound(side_voice) then self.combo_voice = side_voice else self.combo_voice = "full_combo_voice" end audio.play_sound(self.combo_sound, "sound") self.f = 0 return self end function FCAnimation:update(current_ms) self.start_ms = self.start_ms or current_ms self.f = (current_ms - self.start_ms) / FRAME_MS if not self.voice_played and self.f >= VOICE_AT then self.voice_played = true audio.play_sound(self.combo_voice, "voice") end end local function bounce_x(f) if f < BOUNCE[1][1] then return 550 - (550 - BOUNCE[1][2]) * (f / BOUNCE[1][1]) ^ 2 end for i = 2, #BOUNCE do local a, b = BOUNCE[i - 1], BOUNCE[i] if f <= b[1] then return a[2] + (b[2] - a[2]) * (f - a[1]) / (b[1] - a[1]) end end return BOUNCE[#BOUNCE][2] end function FCAnimation:at(t, x, y, p) if not t then return end p = p or {} p.x, p.y = PART_X + x * K + (p.x or 0), self.lane_y + PART_Y + y * K + (p.y or 0) tex.draw_texture(t.id, p) end -- t drawn at swg (x, y), only the part right of swg x CLIP_X function FCAnimation:clipped(t, x, y, p) if not t then return end local cut = math.max(0, (CLIP_X - x) * K) if cut >= t.w then return end p = p or {} p.src = { x = cut, y = 0, width = t.w - cut, height = t.h } p.x2 = -cut p.x = cut self:at(t, x, y, p) end function FCAnimation:draw() local f = self.f if f < UNROLL_AT then self:at(self.scroll, bounce_x(f), SCROLL_Y) return end local u = math.min(1, (f - UNROLL_AT) / (UNROLL_END - UNROLL_AT)) local bx = BANNER_FROM + (BANNER_TO - BANNER_FROM) * (1 - (1 - u) ^ 2.2) self:clipped(self.banner, bx, BANNER_Y) self:clipped(self.text, bx + TEXT_DX, BANNER_Y + TEXT_DY) self:at(self.roller, ROLLER_X, ROLLER_Y) for i, fl in ipairs(self.flowers) do local age = f - (FLOWERS_AT + 4 * ((i - 1) // 2)) if fl and age >= 0 then local s = age < 6 and 1 + (i % 2 == 1 and .28 or .13) * (1 - age / 6) or 1 local pos = FLOWERS[i] self:at(fl, pos[1], pos[2], { x = fl.w * (1 - s) / 2, y = fl.h * (1 - s) / 2, x2 = fl.w * (s - 1), y2 = fl.h * (s - 1) }) end end if f >= FLOWERS_AT then self:clipped(self.text, bx + TEXT_DX, BANNER_Y + TEXT_DY) end -- over the flowers local flash = f - FLASH_AT if flash >= 0 and flash < 10 then local a = flash < 8 and flash / 8 or 1 - (flash - 8) / 2 self:clipped(self.text_white, bx + TEXT_DX, BANNER_Y + TEXT_DY, { fade = a }) end local g = (f - FLASH_AT - 7) / 3 -- the white ghost swells off the text if self.text_white and g >= 0 and g < 1 then local t = self.text_white local sx, sy = 1.16 + .36 * g, 1.3 + .65 * g self:at(t, bx + TEXT_DX, BANNER_Y + TEXT_DY, { x = t.w * (1 - sx) / 2, y = t.h * (1 - sy) / 2, x2 = t.w * (sx - 1), y2 = t.h * (sy - 1), fade = .72 * (1 - g) }) end end