info = { type = "image", title = "Gym lifter", category = "characters", author = "BRRRO", version = "1.0", license = "MIT", desc = "A lifter strains through a heavy rep and cheers", api = 33, } local tr = ({ sk = { ["Outfit"] = "Dres", ["Red"] = "Červený", ["Yellow"] = "Žltý", ["Green"] = "Zelený", ["Purple"] = "Fialový", ["Easy reps"] = "Ľahké opakovania" }, cs = { ["Outfit"] = "Dres", ["Red"] = "Červený", ["Yellow"] = "Žlutý", ["Green"] = "Zelený", ["Purple"] = "Fialový", ["Easy reps"] = "Lehká opakování" }, })[lang] or {} local function T(s) return tr[s] or s end settings = { { key = "outfit", label = T("Outfit"), type = "int", default = "red", opts = { keys = { "red", "yellow", "green", "purple" }, T("Red"), T("Yellow"), T("Green"), T("Purple") } }, { key = "reps", label = T("Easy reps"), type = "int", min = 1, max = 4, default = 2 }, } local rect, px, blend_rect = gfx.rect, gfx.px, gfx.blend_rect local blit_rgb, snapshot = gfx.blit_rgb, gfx.snapshot local floor, sin, cos, sqrt, abs, max, min = math.floor, math.sin, math.cos, math.sqrt, math.abs, math.max, math.min local W, H = gfx.W, gfx.H local SHIRTS = { red = { 232, 72, 86 }, yellow = { 250, 204, 58 }, green = { 60, 190, 120 }, purple = { 156, 104, 232 } } local SKIN, HAIR, EYE = { 244, 200, 160 }, { 92, 56, 36 }, { 30, 24, 28 } local F3, F5 = { font = "3x5" }, { font = "5x7" } local CX, FY = 28, 57 local HIP, CHEST, MID, OVER, FLOOR = 49, 41, 35, 27, 52 local function R(x, y, w, h, c) rect(x, y, w, h, c[1], c[2], c[3]) end local BG = nil local function bake() rect(0, 0, W, 44, 92, 192, 194) rect(0, 32, W, 10, 62, 152, 160); rect(0, 31, W, 1, 230, 236, 230) rect(0, 42, W, 2, 236, 232, 220) rect(4, 5, 18, 19, 244, 244, 236); rect(6, 7, 14, 15, 150, 212, 250) rect(12, 7, 2, 15, 244, 244, 236); rect(6, 14, 14, 2, 244, 244, 236) rect(7, 8, 4, 2, 210, 238, 255) rect(27, 5, 9, 9, 244, 244, 236); rect(28, 6, 7, 7, 250, 250, 246) rect(31, 7, 1, 4, 60, 60, 70); rect(31, 10, 3, 1, 60, 60, 70) rect(40, 4, 21, 13, 40, 44, 60); rect(41, 5, 19, 11, 22, 24, 34) rect(0, 44, W, 20, 222, 152, 84) for i = 0, 3 do local y = 44 + 5 * i rect(0, y, W, 1, 196, 128, 64) for x = (i % 2) * 8, W - 1, 16 do rect(x, y + 1, 1, 4, 196, 128, 64) end end rect(57, 28, 2, 15, 80, 84, 98); rect(53, 42, 10, 2, 54, 58, 72) rect(54, 30, 8, 3, 220, 56, 64); rect(54, 34, 8, 3, 60, 110, 220); rect(55, 38, 6, 3, 54, 58, 72) for dy = -5, 5 do local hw = floor(sqrt(26 - dy * dy) + 0.5) rect(11 - hw, 51 + dy, 2 * hw, 1, 236, 92, 150) end rect(8, 47, 3, 2, 255, 170, 205) BG = snapshot(0, 0, W, H) end local SEG, TOT, SWEAT0 = {}, 1, 0 local function build() SEG = {} local by, hw, cr, vv, t, rep = FLOOR, 0, 0, 0, 0, 1 local function S(dur, to, o) o = o or {} SEG[#SEG + 1] = { t0 = t, dur = dur, by0 = by, by1 = to, hw0 = hw, hw1 = o.hw or hw, cr0 = cr, cr1 = o.cr or cr, vv0 = vv, vv1 = o.vv or vv, face = o.face or 0, amp = o.amp or 0, wob = o.wob or 0, rep = rep, jump = o.jump } t = t + dur by, hw, cr, vv = to, o.hw or hw, o.cr or cr, o.vv or vv end S(10, FLOOR, { hw = 1, cr = 3 }) S(20, HIP, { cr = 0 }) for r = 1, cfg.reps or 2 do rep = r S(12, HIP); S(18, CHEST); S(26, OVER, { face = 1 }); S(14, OVER, { face = 3 }); S(22, CHEST); S(16, HIP) end rep = (cfg.reps or 2) + 1 S(26, HIP); S(24, CHEST, { face = 1 }); S(26, MID, { face = 1 }) SWEAT0 = t S(56, MID, { face = 2, amp = 1, wob = 0.8, cr = 1 }) S(16, OVER, { face = 2, cr = 0 }); S(22, OVER, { face = 3 }); S(26, CHEST); S(16, HIP) S(20, FLOOR, { cr = 3 }); S(10, FLOOR, { hw = 0, cr = 0 }) S(6, FLOOR, { face = 3, vv = 1 }); S(66, FLOOR, { face = 3, jump = true }); S(6, FLOOR, { vv = 0 }) S(40, FLOOR) TOT = t end function on_settings() BG = nil; build() end local function arm(sx, sy, hx, hy, side) local dx, dy = hx - sx, hy - sy local d = sqrt(dx * dx + dy * dy) if d > 11.9 then local k = 11.9 / d dx, dy, d = dx * k, dy * k, 11.9 hx, hy = sx + dx, sy + dy end local h = sqrt(max(0, 36 - d * d / 4)) local nx, ny = -dy / d, dx / d if nx * side < 0 then nx, ny = -nx, -ny end if abs(nx) < 0.3 and ny < 0 then nx, ny = -nx, -ny end return sx + dx / 2 + nx * h, sy + dy / 2 + ny * h, hx, hy end local function limb(x0, y0, x1, y1) local n = max(abs(x1 - x0), abs(y1 - y0), 1) for i = 0, floor(n) do rect(floor(x0 + (x1 - x0) * i / n + 0.5), floor(y0 + (y1 - y0) * i / n + 0.5), 2, 2, SKIN[1], SKIN[2], SKIN[3]) end end local function head(cx, hy, face, shirt) R(cx - 4, hy, 8, 8, SKIN) R(cx - 4, hy, 8, 2, HAIR); R(cx - 4, hy + 2, 1, 2, HAIR); R(cx + 3, hy + 2, 1, 2, HAIR) R(cx - 4, hy + 2, 8, 1, shirt) if face == 0 then px(cx - 2, hy + 4, EYE[1], EYE[2], EYE[3]); px(cx + 1, hy + 4, EYE[1], EYE[2], EYE[3]) rect(cx - 1, hy + 6, 2, 1, 190, 96, 84) elseif face == 1 or face == 2 then R(cx - 3, hy + 4, 2, 1, EYE); R(cx + 1, hy + 4, 2, 1, EYE) px(cx - 3, hy + 3, HAIR[1], HAIR[2], HAIR[3]); px(cx + 2, hy + 3, HAIR[1], HAIR[2], HAIR[3]) if face == 1 then rect(cx - 2, hy + 6, 4, 1, 255, 255, 255); px(cx - 2, hy + 7, 60, 30, 30) else rect(cx - 2, hy + 5, 4, 3, 120, 30, 44); rect(cx - 2, hy + 5, 4, 1, 255, 255, 255) end else px(cx - 2, hy + 4, EYE[1], EYE[2], EYE[3]); px(cx + 1, hy + 4, EYE[1], EYE[2], EYE[3]) rect(cx - 2, hy + 5, 4, 2, 120, 30, 44); rect(cx - 2, hy + 5, 4, 1, 255, 255, 255) blend_rect(cx - 4, hy + 5, 2, 2, 255, 120, 140, 0.6); blend_rect(cx + 2, hy + 5, 2, 2, 255, 120, 140, 0.6) end end local function bar(bx, by) rect(bx - 20, by, 40, 1, 190, 194, 204) for _, s in ipairs({ -1, 1 }) do local x = s < 0 and bx - 17 or bx + 14 rect(x, by - 4, 3, 9, 214, 54, 62); rect(x + (s < 0 and 0 or 2), by - 4, 1, 9, 150, 30, 44) local x2 = s < 0 and bx - 19 or bx + 17 rect(x2, by - 3, 2, 7, 54, 58, 72) rect(s < 0 and bx - 14 or bx + 13, by - 1, 1, 3, 220, 224, 232) end end local function sparkle(i, c) local a = i * 1.26 + c * 0.04 local x, y = floor(CX + 17 * cos(a) + 0.5), floor(30 + 12 * sin(a * 1.3) + 0.5) if (c // 4 + i) % 3 ~= 0 then rect(x - 1, y, 3, 1, 255, 240, 120); rect(x, y - 1, 1, 3, 255, 240, 120) else px(x, y, 255, 255, 255) end end function render() if not BG then bake() else blit_rgb(BG, 0, 0, W, H) end local c = frame % TOT local s = SEG[#SEG] for i = 1, #SEG do if c < SEG[i].t0 + SEG[i].dur then s = SEG[i]; break end end local u = (c - s.t0) / s.dur local e = u * u * (3 - 2 * u) local by = s.by0 + (s.by1 - s.by0) * e + s.wob * sin(c * 0.9) local hw = s.hw0 + (s.hw1 - s.hw0) * u local cr = floor(s.cr0 + (s.cr1 - s.cr0) * e + 0.5) local vv = s.vv0 + (s.vv1 - s.vv0) * u local jh = 0 if s.jump then local q = ((c - s.t0) % 22) / 22 jh = floor(28 * q * (1 - q) + 0.5) end local dx = s.amp > 0 and s.amp * (((c // 2) % 2) * 2 - 1) or 0 local cx = CX + dx local shirt = SHIRTS[cfg.outfit] or SHIRTS.red local bd = -jh blend_rect(CX - 7, FY, 14, 1, 0, 0, 0, 0.25); blend_rect(CX - 5, FY + 1, 10, 1, 0, 0, 0, 0.2) local fy = FY + bd rect(cx - 5, fy - 2, 5, 2, 244, 244, 248); rect(cx + 1, fy - 2, 5, 2, 244, 244, 248) local sh = max(1, 3 - cr) R(cx - 4, fy - 2 - sh, 3, sh, SKIN); R(cx + 1, fy - 2 - sh, 3, sh, SKIN) local top = FY - 10 + cr + bd rect(cx - 5, top, 4, fy - 2 - sh - top, 50, 90, 200); rect(cx + 1, top, 4, fy - 2 - sh - top, 50, 90, 200) rect(cx - 1, top, 2, 3, 50, 90, 200) local ty = top - 9 R(cx - 5, ty, 10, 9, shirt) rect(cx - 5, ty + 2, 1, 7, floor(shirt[1] * 0.75), floor(shirt[2] * 0.75), floor(shirt[3] * 0.75)) R(cx - 1, ty - 1, 2, 1, SKIN) head(cx, ty - 9, s.face, shirt) local sy = ty + 1 local hy_grip = by + 1 local fl = { cx - 7, sy + 9 + 0 } local fr = { cx + 6, sy + 9 } local vl, vr = { cx - 9, sy - 9 }, { cx + 8, sy - 9 } local lx = fl[1] + (vl[1] - fl[1]) * vv local ly = fl[2] + (vl[2] - fl[2]) * vv local rx = fr[1] + (vr[1] - fr[1]) * vv local ry = fr[2] + (vr[2] - fr[2]) * vv lx = lx + (cx - 8 - lx) * hw; ly = ly + (hy_grip - ly) * hw rx = rx + (cx + 7 - rx) * hw; ry = ry + (hy_grip - ry) * hw local ex, ey, hx, hy = arm(cx - 5, sy, lx, ly, -1) limb(cx - 5, sy, ex, ey); limb(ex, ey, hx, hy) local ex2, ey2, hx2, hy2 = arm(cx + 4, sy, rx, ry, 1) limb(cx + 4, sy, ex2, ey2); limb(ex2, ey2, hx2, hy2) if hw > 0.5 then bar(cx, floor(by + 0.5)) else bar(CX, FLOOR) end R(floor(hx), floor(hy), 2, 2, SKIN); R(floor(hx2), floor(hy2), 2, 2, SKIN) for i = 0, 11 do local age = c - (SWEAT0 + 7 * i) if age >= 0 and age < 24 and c < SWEAT0 + 56 + 16 then local side = i % 2 == 0 and -1 or 1 local x = cx + side * 5 + side * 0.7 * age local y = ty - 9 + 3 - 1.5 * age + 0.08 * age * age rect(floor(x + 0.5), floor(y + 0.5), 1, 2, 150, 210, 255) px(floor(x + 0.5), floor(y + 0.5), 235, 248, 255) end end if s.jump then for i = 0, 4 do sparkle(i, c) end end gfx.text(42, 8, "REP", 255, 184, 64, F3) gfx.text(55, 6, tostring(s.rep), 255, 184, 64, F5) end