Making a pet: the folder

A pet starts as a folder of sprite sheets, which tools/eggpack/eggpack.py checks and packs into one .egg file (egg-format.md). The layout is AnimData.xml plus one <Name>-Anim.png sheet per animation, the convention used by common sprite collections. pets/goose/ is a complete example.

mypet/
  AnimData.xml          the animations: names, frame size, how long each frame shows
  Idle-Anim.png         one sprite sheet per animation
  Walk-Anim.png
  ...
  pet.json              optional: name, words about the pet, credit and licence, its own scene
  meadow.png ...        optional: scene pictures that pet.json names
python3 tools/eggpack/eggpack.py mypet --check                        # what each state will play, and any errors
python3 tools/eggpack/eggpack.py mypet -o ~/.nestbox/pets/mypet.egg   # pack it; the simulator picks it up

The packer asks the engine which animations each state plays, so build it first, on any platform: cmake -S . -B build && cmake --build build (or point NESTBOX_BUILD_DIR at another build).

Sprite sheets

AnimData.xml

<AnimData>
  <Anims>
    <Anim>
      <Name>Walk</Name>
      <FrameWidth>32</FrameWidth>
      <FrameHeight>40</FrameHeight>
      <Durations><Duration>8</Duration><Duration>8</Duration><Duration>8</Duration><Duration>8</Duration></Durations>
    </Anim>
    <Anim><Name>Strike</Name><CopyOf>Attack</CopyOf></Anim>
  </Anims>
</AnimData>

What the pet must have

pet.json

{
  "name": "Goose",
  "credit": "NestBox",
  "license": "CC BY 4.0",
  "scale": 2,
  "theme": "A white farm goose on a Swiss mountain farm: ...",
  "notes": { "RearUp": "the goose hiss: neck low and forward, wings spread (grumpy)" },
  "scene": {
    "background": "meadow.png",
    "night": "meadow_night.png",
    "scale": 2,
    "keep": [50, 50, 136, 119],
    "floor": [[52, 54], [138, 54], [138, 69], [112, 71], [94, 88], [77, 111], [80, 118], [4, 118], [4, 94]],
    "home": [72, 102],
    "workspot": { "at": [74, 59], "on": "workspot_on.png", "off": "workspot_off.png", "night": "workspot_night.png" }
  }
}

(The goose's floor has more points; this is a shortened copy of pets/goose/pet.json.)

The hoop shot (optional)

A pet can shoot a ball at something in its scene while the user types fast, instead of playing WorkFast. It needs:

How the device flies the ball is in egg-format.md. The goose has no hoop shot.

Checking and loading

Art from a third-party sprite collection keeps its own licence. Check it before you share an egg made from it.