# QxSprite and MysteryForge

[QxSprite](https://qxsprite.waxquixotic.com) is a free pixel-art sprite and animation editor (MIT licence; Windows, macOS, Linux) with its own MCP server, a command line, and sprite sheets in the same JSON format Aseprite writes. It is a natural partner for MysteryForge: draw a character's walk, a flickering lamp or a ticking clock in QxSprite, export a sheet, and MysteryForge plays it. An AI agent can drive both tools at once.

This page covers: what MysteryForge plays, the export settings that fit it, a helper that writes the MysteryForge JSON for you, and three ways to work — by hand, from the command line, and agent to agent.

## What MysteryForge can play from QxSprite

| In the game | What it is | MysteryForge field |
|---|---|---|
| A person standing or walking in a room | an **actor pose**: `idle`, `walk`, `talk`, a gesture | a character's `actor.poses.<name>` (`image`, `frames` or `sheet`) |
| Mouth shapes that follow the voice | an actor's `talk` pose: closed mouth first, widest last | `actor.poses.talk.frames` |
| A blink | the idle picture with the eyes shut | `actor.poses.blink` + `actor.life.blink` |
| Something moving in a room (a fire, a clock, a bird) | an **overlay** animation | a scene overlay's `sheet` or `frames` |
| A face in conversation | a **portrait** (512 × 512), or talk frames | a character's `portrait`, `talk_frames` |
| An inventory item | an **item icon** (256 × 256) | an item's `icon` |

The rules the engine reads sheets by (format spec, "Animation" and "Actors"):

- A sheet is cut into equal cells **left to right, top to bottom, starting at the top-left cell**: `"sheet": {"image": "...", "columns": 4, "rows": 1, "count": 4}` (`count` only when the last row is not full), played at `fps`, looping unless `"loop": false`.
- **One animation per sheet.** The engine plays a whole sheet; it does not pick a tag's row out of a bigger sheet. Export each tag on its own.
- **No trimming, no spacing, no border.** Every frame keeps the full canvas so a figure's feet never jump. QxSprite never trims, so this is the default; just leave `--spacing` and `--border` at 0.
- **One speed per animation.** Frames with different durations play at one `fps`; to hold a pose longer, repeat its frame.
- **Forward only.** A ping-pong tag must be exported with its frames written out in play order.
- **Transparent background** for anything that stands in a room (QxSprite's default).

## Size: scale up when you export

A room is 1920 × 1080 and a standing figure is usually 40–70% of the picture's height, so a 64-pixel-tall sprite is drawn at 400–750 pixels. Godot draws textures with smooth filtering, which would blur pixel art scaled up that far. So **export at the size it will be shown**, with QxSprite's nearest-neighbour `--scale` (whole numbers, 1–64): a 64-pixel figure that should stand half the screen tall (540 px) exports at `--scale 8` (512 px) or `--scale 9`. The engine then only scales down a little, and the pixels stay crisp.

For the web build, keep both sides of a sheet a **multiple of 4** if you import it VRAM-compressed (WebGL draws a compressed texture with other sides as black). Lossless import (the default) has no such rule.

## The helper: sheet JSON → MysteryForge JSON

`integrations/sprite_sheet.py` (in the MysteryForge download; Python 3, no packages) reads the JSON QxSprite writes beside a sheet and prints the block MysteryForge needs, with the grid, frame count and speed worked out. It also tells you when the engine could not play the sheet as it stands, and what to export instead.

```bash
python3 integrations/sprite_sheet.py walk.json --asset game/assets/actors/hartley_walk.png
```

```json
{
  "sheet": {
    "image": "game/assets/actors/hartley_walk.png",
    "columns": 4,
    "rows": 1
  },
  "fps": 10
}
```

Options: `--tag NAME` (check that one tag is the whole sheet), `--as overlay` (a scene overlay; same block) or `--as portrait` (a living-portrait loop: `image`, `columns`, `rows`, `count`, `fps`), `--fps N` to override the speed. It exits with 1 and prints `problem:` lines when the layout will not play (spacing, a border, trimmed or rotated frames, uneven cells, a tag that is not the whole sheet), and `note:` lines for things worth knowing (mixed durations, ping-pong, non-multiple-of-4 sides).

It reads any Aseprite-format sheet, so it works for Aseprite, LibreSprite and Pixelorama exports too.

## Way 1: by hand

1. In QxSprite, draw the figure on a transparent canvas. Make a tag per animation (`idle`, `walk`, `talk`, `blink`), each frame the same canvas size, with the feet at the same place on every frame (bottom-centre is the engine's default anchor).
2. **File → Export sprite sheet**: layout *Horizontal* (or *Grid*), *Tag*: the one animation, *Scale*: see above, *Spacing* 0, *Border* 0, JSON *Hash*. Save it into your game: `game/assets/actors/<character>_<pose>.png`.
3. Run the helper on the JSON (or read the grid off the sheet yourself), then in **MysteryForge Studio → Characters → (the character) → Actor → Poses**, add the pose with the sheet's picture, columns, rows and speed.
4. Put the character in a room: **Scenes → (room) → In the room (actor)**, place them, and press **Play here**.

A one-frame pose (a still `idle`, a `point` gesture) is simplest as a single PNG: **File → Export PNG** (`--png`, with `--frame N`).

## Way 2: the command line

QxSprite's command line exports straight into the game folder. Run it as `QxSprite --cli …` from the app, or `node <QxSprite>/resources/cli/qxsprite.cjs …` (below, `qxsprite` stands for either):

```bash
GAME=~/Games/the-lighthouse
for pose in idle walk talk; do
  qxsprite export keeper.qxs --sheet "$GAME/game/assets/actors/keeper_$pose.png" --tag "$pose" --scale 8 --json hash
  python3 integrations/sprite_sheet.py "$GAME/game/assets/actors/keeper_$pose.json" \
          --asset "game/assets/actors/keeper_$pose.png" > "/tmp/keeper_$pose.pose.json"
done
qxsprite export keeper.qxs --png "$GAME/game/assets/portraits/keeper.png" --frame 0 --scale 8
```

The `.json` files beside the sheets are harmless in the game folder (nothing references them), but you can delete them once the poses are in. Then add the poses to the character (Studio, or an agent's `upsert_character`), and run `./mysteryforge import <game>` so Godot imports the new pictures.

Individual frames instead of a sheet (for a `talk` pose's mouth shapes, closed first and widest last): `qxsprite export keeper.qxs --frames "out/keeper_talk_{frame}.png" --tag talk --scale 8` and list them in `poses.talk.frames`.

## Way 3: agent to agent (two MCP servers)

An agent attached to both QxSprite's MCP server and MysteryForge's can do the whole round trip. Attach both (Claude Code shown; paths for a macOS install):

```bash
claude mcp add qxsprite -e ELECTRON_RUN_AS_NODE=1 -- "/Applications/QxSprite.app/Contents/MacOS/QxSprite" "/Applications/QxSprite.app/Contents/Resources/cli/qxsprite.cjs" mcp
claude mcp add mysteryforge -- /path/to/MysteryForge/mysteryforge mcp ~/Games/the-lighthouse
```

QxSprite's server works live inside the open editor (you watch the agent draw) or headless when the editor is closed. A typical request:

> *"In QxSprite, draw a 48×96 lighthouse keeper in an oilskin with a 4-frame walk and a 3-frame talk (mouth closed, half, open). Export each as a sheet into the lighthouse game's actors folder at scale 6, then give the keeper those poses in MysteryForge, put him by the lamp in the lantern room, and show me a screenshot."*

The agent's steps: QxSprite `new_sprite`, drawing tools, `frame`, `tag`, `export_spritesheet` (path inside the game, `tag`, `scale`, `json: "hash"`) → MysteryForge `import_assets` (or the files are already in place) → `upsert_character` with `actor.poses` → `update_scene` to stand the actor in the room → `validate_project` → `screenshot_scene`. The details for agents are in [art-integrations.md](https://mysteryforge.vivalainsurreccion.com/agents/art-integrations/).

## Checklist

- [ ] one tag per sheet; frames in play order; same canvas on every frame
- [ ] transparent background; feet at the same spot on every frame
- [ ] exported at the size it will be shown (`--scale`), spacing 0, border 0
- [ ] saved under `game/assets/…`, referenced by its project path
- [ ] `./mysteryforge import <game>` after adding pictures, then `validate_project` (0 errors) and a look with **Play here** or `screenshot_scene`
