info = { type = "image", title = "Burger drop", category = "food", author = "BRRRO", version = "1.0", license = "MIT", desc = "Juicy burger: the bun hops, layers squish", api = 33, } local tr = ({ sk = { ["Background"] = "Pozadie", ["Bun hop"] = "Skok žemle", ["Steam"] = "Para", ["Falling cheese drop"] = "Padajúci syr" }, cs = { ["Background"] = "Pozadí", ["Bun hop"] = "Skok housky", ["Steam"] = "Pára", ["Falling cheese drop"] = "Padající sýr" }, })[lang] or {} local function T(s) return tr[s] or s end settings = { { key = "bg", label = T("Background"), type = "color", default = "#35C9C0" }, { key = "hop", label = T("Bun hop"), type = "bool", default = true }, { key = "steam", label = T("Steam"), type = "bool", default = true }, { key = "drip", label = T("Falling cheese drop"), type = "bool", default = true }, } local floor, sin, sqrt, exp = math.floor, math.sin, math.sqrt, math.exp local rect, px, blend, blend_rect = gfx.rect, gfx.px, gfx.blend, gfx.blend_rect local W, H, FPS = gfx.W, gfx.H, gfx.FPS local STEP_HZ = 30 local TAU = 6.283185 local CX, BASE = 32, 54 local OUT = { 74, 36, 24 } local BUN = { 224, 134, 56 } local BUN_L = { 242, 162, 76 } local BUN_D = { 190, 102, 42 } local CUT = { 250, 214, 150 } local SHINE = { 255, 222, 168 } local SEED = { 255, 244, 206 } local PAT = { 122, 64, 38 } local PAT_L = { 150, 84, 50 } local PAT_D = { 92, 46, 28 } local SPK = { 168, 100, 62 } local CH = { 255, 202, 46 } local LET = { 104, 196, 60 } local LET_L = { 150, 226, 92 } local LET_D = { 70, 160, 46 } local TOM = { 228, 58, 52 } local TOM_D = { 182, 36, 40 } local function row(y, hw, c) rect(CX - hw - 1, y, 2 * hw + 2, 1, OUT[1], OUT[2], OUT[3]) rect(CX - hw, y, 2 * hw, 1, c[1], c[2], c[3]) end local function hgt(h, k, c) local v = floor(h * (1 - c * k) + 0.5) return v < 1 and 1 or v end local function wid(w, k, c) return w + floor(w * c * k * 0.3 + 0.5) end local function anim(p) local c, lift = 0, 0 if p >= 100 and p < 124 then local u = p - 100; lift = 2.667 * u - 0.1111 * u * u elseif p >= 124 and p < 136 then local u = p - 124; lift = 1.333 * u - 0.1111 * u * u end if p >= 100 then local u = p - 100; c = c - 0.07 * exp(-u / 8) * sin(TAU * u / 14) end if p >= 124 then local u = p - 124; c = c + 0.24 * exp(-u / 10) * sin(TAU * u / 14) end if p >= 136 then local u = p - 136; c = c + 0.10 * exp(-u / 10) * sin(TAU * u / 14) end return c, lift end local SPECKS = { { -0.7, 0.2 }, { -0.35, 0.7 }, { 0.05, 0.3 }, { 0.4, 0.75 }, { 0.7, 0.35 }, { -0.1, 0.9 } } local SEEDS = { { -0.45, 0.24 }, { 0.08, 0.16 }, { 0.48, 0.32 }, { -0.16, 0.44 }, { 0.28, 0.56 }, { -0.62, 0.56 }, { 0.62, 0.66 }, { -0.36, 0.7 } } local WISP = { 23, 32, 41 } local BG, BR, BGc, BB = nil, 53, 201, 192 local function build_bg() gfx.clear(BR, BGc, BB) local hr = BR + (255 - BR) * 22 // 100 local hg = BGc + (255 - BGc) * 22 // 100 local hb = BB + (255 - BB) * 22 // 100 for y = 11, 63 do local d = 27 * 27 - (y - 38) * (y - 38) if d >= 0 then local hw = floor(sqrt(d) + 0.5) rect(CX - hw, y, 2 * hw, 1, hr, hg, hb) end end local sr, sg, sb = BR * 74 // 100, BGc * 74 // 100, BB * 74 // 100 rect(CX - 21, 55, 42, 1, sr, sg, sb) rect(CX - 24, 56, 48, 1, sr, sg, sb) rect(CX - 22, 57, 44, 1, sr, sg, sb) rect(CX - 16, 58, 32, 1, sr, sg, sb) BG = gfx.snapshot(0, 0, W, H) end local HOP, STEAM, DRIP = true, true, true function on_settings() local c = cfg.bg or { r = 53, g = 201, b = 192 } BR, BGc, BB = c.r, c.g, c.b BG = nil HOP = cfg.hop ~= false STEAM = cfg.steam ~= false DRIP = cfg.drip ~= false end local function steam(t) for w = 1, 3 do for k = 0, 4 do local a = (t + k * 14 + w * 23) % 70 local al = 0.5 * (1 - a / 70) if a < 8 then al = al * a / 8 end local y = 19 - a * 0.3 local iy = floor(y) local f = y - iy local x = WISP[w] + floor(1.5 * sin(k * 1.9 + w) + 0.5) blend(x, iy, 255, 255, 255, al * (1 - f)) blend(x, iy + 1, 255, 255, 255, al * f) end end end local function drip(t, xd, yb) local q = t % 240 if q < 150 then local L = 1 + q / 150 * 4 local n = floor(L) rect(xd, yb + 1, 2, n, CH[1], CH[2], CH[3]) blend_rect(xd, yb + 1 + n, 2, 1, CH[1], CH[2], CH[3], L - n) elseif q < 195 then local a = q - 150 rect(xd, yb + 1, 2, 1, CH[1], CH[2], CH[3]) local y = yb + 4 + 0.06 * a * a if y < 55 then rect(xd, floor(y), 2, 2, CH[1], CH[2], CH[3]) else local al = 1 - (a - 15) / 30 if al > 0 then blend_rect(xd - 1, 56, 4, 1, CH[1], CH[2], CH[3], al > 1 and 1 or al) end end else rect(xd, yb + 1, 2, 1, CH[1], CH[2], CH[3]) end end function render() if not BG then build_bg() else gfx.blit_rgb(BG, 0, 0, W, H) end local t = frame * STEP_HZ // FPS if STEAM then steam(t) end local c, lift = 0, 0 if HOP then c, lift = anim(t % 180) end local y = BASE local h, hw = hgt(6, 1.2, c), wid(19, 1.2, c) local top = y - h + 1 for r = 0, h - 1 do local w = hw if r == h - 1 then w = hw - 3 elseif r == h - 2 then w = hw - 1 end row(top + r, w, r == 0 and CUT or (r == h - 1 and BUN_D or BUN)) end rect(CX - hw + 3, y + 1, 2 * (hw - 3), 1, OUT[1], OUT[2], OUT[3]) y = top - 1 h, hw = hgt(6, 0.6, c), wid(21, 0.6, c) top = y - h + 1 for r = 0, h - 1 do local w = (r == 0 or r == h - 1) and hw - 1 or hw row(top + r, w, r == h - 1 and PAT_D or (r == 0 and PAT_L or PAT)) end for i = 1, #SPECKS do local s = SPECKS[i] px(CX + floor(s[1] * hw), top + 1 + floor(s[2] * (h - 2)), SPK[1], SPK[2], SPK[3]) end y = top - 1 h, hw = hgt(2, 0.3, c), wid(22, 0.3, c) top = y - h + 1 for r = 0, h - 1 do row(top + r, hw, CH) end rect(CX - hw + 2, y + 1, 3, 2, CH[1], CH[2], CH[3]); px(CX - hw + 3, y + 3, CH[1], CH[2], CH[3]) rect(CX + hw - 11, y + 1, 3, 1, CH[1], CH[2], CH[3]); px(CX + hw - 10, y + 2, CH[1], CH[2], CH[3]) if DRIP then drip(t, CX + hw - 5, y) end y = top - 1 h, hw = hgt(2, 0.4, c), wid(23, 0.4, c) top = y - h + 1 for r = 0, h - 1 do row(top + r, hw, r == 0 and LET_L or LET) end for x = CX - hw + 1, CX + hw - 2, 4 do rect(x, y + 1, 2, 1, LET_D[1], LET_D[2], LET_D[3]) end y = top - 1 h, hw = hgt(2, 0.5, c), wid(19, 0.5, c) top = y - h + 1 for r = 0, h - 1 do row(top + r, hw, r == 0 and TOM or TOM_D) end y = top - 1 local cb = lift > 0 and 0 or c local hd = hgt(15, 1.0, cb) hw = wid(20, 1.0, cb) local yb = y - floor(lift + 0.5) top = yb - hd + 1 local w0, w2 = 0, 0 for r = 0, hd - 1 do local w, col if r == hd - 1 then w, col = hw - 1, CUT else local yy = (hd - 1.5 - r) / (hd - 1) w = floor(hw * sqrt(1 - yy * yy) + 0.5) col = r < (hd - 1) * 0.4 and BUN_L or BUN end if r == 0 then w0 = w elseif r == 2 then w2 = w end row(top + r, w, col) end rect(CX - w0, top - 1, 2 * w0, 1, OUT[1], OUT[2], OUT[3]) if lift >= 0.5 then rect(CX - hw + 2, yb + 1, 2 * (hw - 2), 1, OUT[1], OUT[2], OUT[3]) end local sx = CX - floor(w2 * 0.6) rect(sx, top + 2, 4, 1, SHINE[1], SHINE[2], SHINE[3]) rect(sx - 1, top + 3, 2, 1, SHINE[1], SHINE[2], SHINE[3]) local gi, gp = (t // 40) % #SEEDS + 1, t % 40 for i = 1, #SEEDS do local s = SEEDS[i] local rr = floor(s[2] * (hd - 1)) local yy = (hd - 1.5 - rr) / (hd - 1) local wr = hw * sqrt(1 - yy * yy) local x, ys = CX + floor(s[1] * wr), top + rr rect(x, ys, 2, 1, SEED[1], SEED[2], SEED[3]) if i == gi and gp < 10 then local a = 1 - (gp - 5 < 0 and 5 - gp or gp - 5) / 5 blend(x, ys, 255, 255, 255, a) blend(x - 1, ys, 255, 255, 255, a * 0.7); blend(x + 2, ys, 255, 255, 255, a * 0.7) blend(x, ys - 1, 255, 255, 255, a * 0.7); blend(x, ys + 1, 255, 255, 255, a * 0.7) end end end