info = { type = "image", title = "Ocean", category = "animals", author = "BRRRO", version = "1.0", license = "MIT", desc = "A whale leaps above the surface", api = 33, } local SEA = 33 local WHALE = { "..####..", ".######.", "########", "###..###", ".######.", "..####.." } local BODY, bn = {}, 0 for r = 1, #WHALE do local row, x0 = WHALE[r], nil for c = 1, 9 do local on = c <= 8 and row:sub(c, c) == "#" if on and not x0 then x0 = c end if not on and x0 then BODY[bn + 1], BODY[bn + 2], BODY[bn + 3] = x0 - 1, r - 1, c - x0 bn = bn + 3 x0 = nil end end end local WS, WC = nil, nil function render() local W, H = gfx.W, gfx.H local t = frame / gfx.FPS local rect, px, floor = gfx.rect, gfx.px, math.floor if not WS then WS, WC = {}, {} for x = 0, W - 1 do WS[x], WC[x] = math.sin(x * 0.2), math.cos(x * 0.2) end end for y = 0, SEA - 1 do local f = y / SEA rect(0, y, W, 1, 154 + 58 * f, 200 + 30 * f, 238 + 10 * f) end for y = SEA, H - 1 do local f = (y - SEA) / (H - SEA) rect(0, y, W, 1, 46 - 24 * f, 120 - 44 * f, 180 - 42 * f) end local a = t * 3.6 local ca, sa = math.cos(a), math.sin(a) local x0, wp = 0, nil for x = 0, W do local wy = nil if x < W then wy = SEA + floor(2 * (WS[x] * ca + WC[x] * sa) + 0.5) end if wy ~= wp then if wp then rect(x0, wp, x - x0, 1, 160, 208, 236) end x0, wp = x, wy end end local p = (t * 0.24) % 1 local wx = floor(10 + p * 38 + 0.5) local wy = floor(42 - math.sin(p * math.pi) * 24 + 0.5) for i = 1, #BODY, 3 do rect(wx + BODY[i], wy + BODY[i + 1], BODY[i + 2], 1, 64, 74, 100) end px(wx - 1, wy + 1, 64, 74, 100) px(wx + 8, wy, 64, 74, 100) px(wx + 9, wy - 1, 64, 74, 100) for i = 0, 4 do local fy = floor(wy - 2 - (t * 18 + i * 4) % 10) if fy > 0 then px(wx + 3 + i % 2, fy, 222, 238, 250) end end end