-- gen_extras.lua — 5 background critters (each 32x24: 2-frame walk loop)
-- squirrel / hedgehog / fox / pig / chick  (profile, facing left)
local ROOT = "/Users/leidianyayi/Documents/GitHub/ModelTest20260714/Kimi-K3/"
local H = dofile(ROOT .. "tools/aseprite/helpers.lua")

local function squirrel(t, f)
  t.discn(11, 9, 4, "honey_d"); t.discn(12, 6, 3, "honey"); t.pn(13, 4, "honey_l") -- bushy tail
  t.ellipsen(6, 15, 5, 4, "honey")
  t.ellipsen(6, 16, 3, 2, "cream")
  t.discn(4, 10, 3, "honey")
  t.pn(2, 7, "honey"); t.pn(3, 7, "honey"); t.pn(2, 8, "honey_d")                  -- ear
  t.pn(2, 10, "ink"); t.pn(1, 12, "brown_d")                                        -- eye / nose
  if f == 0 then t.rectn(4, 19, 2, 3, "brown_d"); t.rectn(8, 19, 2, 3, "brown_d")
  else t.rectn(3, 19, 2, 3, "brown_d"); t.rectn(9, 19, 2, 2, "brown_d") end
end

local function hedgehog(t, f)
  t.discn(8, 13, 7, "brown_d")                                                       -- spiny body
  t.discn(8, 13, 6, "brown_l")
  for _, p in ipairs({ { 4, 8 }, { 7, 7 }, { 10, 8 }, { 12, 10 }, { 5, 11 }, { 9, 11 }, { 12, 13 } }) do
    t.pn(p[1], p[2], "brown_dd")                                                     -- spines
  end
  t.discn(3, 14, 3, "cream_d")                                                       -- face
  t.pn(2, 13, "ink"); t.pn(0, 15, "brown_dd")                                        -- eye / nose
  t.pn(3, 16, "brown_d")
  if f == 0 then t.rectn(5, 19, 2, 2, "brown_d"); t.rectn(9, 19, 2, 2, "brown_d")
  else t.rectn(4, 19, 2, 2, "brown_d"); t.rectn(10, 19, 2, 2, "brown_d") end
end

local function fox(t, f)
  t.discn(12, 13, 4, "honey_d"); t.pn(14, 12, "cream"); t.pn(15, 13, "cream")        -- tail, white tip
  t.ellipsen(7, 15, 5, 4, "honey")                                                   -- body
  t.rectn(3, 6, 2, 3, "honey"); t.rectn(6, 6, 2, 3, "honey")                         -- ears
  t.pn(3, 6, "brown_d"); t.pn(6, 6, "brown_d")
  t.discn(4, 10, 4, "honey")                                                         -- head
  t.rectn(1, 11, 3, 3, "honey")                                                      -- snout
  t.pn(1, 12, "ink"); t.pn(3, 9, "ink")                                              -- nose / eye
  t.rectn(1, 13, 3, 2, "cream")                                                      -- cheek
  if f == 0 then t.rectn(5, 19, 2, 3, "brown_d"); t.rectn(9, 19, 2, 3, "brown_d")
  else t.rectn(4, 19, 2, 3, "brown_d"); t.rectn(10, 19, 2, 2, "brown_d") end
end

local function pig(t, f)
  t.ellipsen(8, 14, 6, 5, "pink")                                                    -- round body
  t.pn(13, 12, "pink_d"); t.pn(14, 11, "pink_d"); t.pn(14, 13, "pink_d")             -- curly tail
  t.discn(4, 10, 4, "pink")                                                          -- head
  t.rectn(2, 6, 2, 3, "pink"); t.rectn(6, 6, 2, 3, "pink"); t.pn(2, 6, "pink_d"); t.pn(6, 6, "pink_d") -- ears
  t.rectn(1, 11, 3, 3, "pink_d")                                                     -- snout
  t.pn(2, 12, "pink_dd"); t.pn(3, 12, "pink_dd")                                     -- nostrils
  t.pn(3, 9, "ink")                                                                  -- eye
  if f == 0 then t.rectn(5, 19, 2, 3, "pink_d"); t.rectn(9, 19, 2, 3, "pink_d")
  else t.rectn(4, 19, 2, 3, "pink_d"); t.rectn(10, 19, 2, 2, "pink_d") end
end

local function chick(t, f)
  t.discn(8, 13, 5, "yellow")                                                        -- body
  t.discn(5, 9, 3, "yellow")                                                         -- head
  t.pn(5, 6, "yellow"); t.pn(6, 7, "yellow")                                         -- tuft
  t.discn(9, 13, 2, "yellow_d")                                                      -- wing
  t.pn(2, 9, "honey"); t.pn(1, 9, "honey_d")                                         -- beak
  t.pn(4, 8, "ink")                                                                  -- eye
  t.pn(11, 11, "yellow_d"); t.pn(12, 10, "yellow_d")                                 -- tail
  if f == 0 then t.vln(6, 18, 3, "honey_d"); t.vln(9, 18, 3, "honey_d")
  else t.vln(5, 18, 3, "honey_d"); t.vln(10, 18, 2, "honey_d") end
end

local extras = {
  { "squirrel", squirrel }, { "hedgehog", hedgehog }, { "fox", fox },
  { "pig", pig }, { "chick", chick },
}
for _, n in ipairs(extras) do
  local spr, img = H.new(32, 24)
  n[2](H.at(img, 0, 0), 0)
  n[2](H.at(img, 16, 0), 1)
  spr:saveAs(ROOT .. "public/assets/sprites/extra_" .. n[1] .. ".png")
  print("extra_" .. n[1] .. ".png done")
end
