星露谷风格四向/八向移动帧自动化技能
Generate Stardew Valley-style top-down pixel-art RPG character movement sprites. Supports 4-directional or 8-directional walking cycles with configurable frame count, using cloud AI image APIs (即梦 by ByteDance, or OpenAI DALL-E) with automated post-processing.
Flow: API Setup First (ALWAYS start here)
When this skill is invoked, the VERY FIRST thing you do is check whether an API key is configured. Nothing else happens before this check.
python -c "
from sprite_gen.utils.config import get_api_key
for api in ['openai', 'jimeng']:
key = get_api_key(api)
print(f'{api}: {\"configured\" if key else \"NOT configured\"}')"
If NO API key is configured
Immediately ask the user to provide one. Do NOT discuss generation parameters until this is done.
Ask: "请选择生图 API:即梦(字节跳动)还是 OpenAI(DALL-E)?"
After they pick, ask: "请提供 API Key:"
Save it:
python -c "
from sprite_gen.utils.config import set_api_key, set_default_api
set_api_key('<openai|jimeng>', '<用户提供的KEY>')
set_default_api('<openai|jimeng>')
print('API Key 已保存。')"
- Verify:
python -c "
from sprite_gen.adapters.openai_image import OpenAIImageAdapter
adapter = OpenAIImageAdapter()
print('API 可用' if adapter.health_check() else 'API Key 无效或无法连接')"
(Use JimengAdapter if user chose 即梦.)
- Once verified, say "API 就绪,可以开始生成精灵了。" and proceed to the generation flow below.
If API key IS already configured
Say which API is configured and go straight to generation flow:
"当前使用 {openai/即梦} API。开始生成精灵吗?"
Generation Flow (only after API is confirmed working)
Step 1: Gather Parameters
Ask one question at a time:
- 角色描述(中文): e.g. "银甲蓝披风的年轻骑士"
- Character description (English): e.g. "young knight with silver armor and blue cape"
- 运动方向: 四向 (S/W/N/E) 还是八向 (增加 SW/NW/NE/SE)?
- 每方向帧数: 4 还是 8?
- 角色尺寸: 16 / 32 / 48 / 64 px?
- 输出格式: 独立帧 / 精灵表 / 都要?
Step 2: Confirm
Summary:
· 角色: {character_cn}
· API: {api}
· 方向: {count} ({list})
· 帧/方向: {n} (共 {total} 帧)
· 尺寸: {size}×{size}px
· 输出: {format}
· 目录: ./sprites/{name}-{date}/
开始生成?[Y/n]
Step 3: Run
python -m sprite_gen.main \
--api {openai|jimeng} \
--character "{english description}" \
--character-cn "{中文描述}" \
--directions {ALL4|ALL8|S,W,N,E} \
--frames {4|8} \
--size {16|32|48|64} \
--output-format {frames|sheet|both} \
--output-dir ./sprites
This may take several minutes. The script prints per-frame progress. Each frame is saved individually — re-running with the same output directory will skip already-generated frames (resume support).
Step 4: Review
List results:
ls ./sprites/{name}-{date}/
ls ./sprites/{name}-{date}/frames/ | head -20
Ask if the user wants to regenerate specific directions.
Regenerate Specific Directions
python -m sprite_gen.main \
--api {api} \
--character "{english}" \
--character-cn "{中文}" \
--directions {W,NW} \
--frames {n} \
--size {size} \
--output-format both \
--output-dir ./sprites/{existing-dir}
Output Structure
./sprites/{character}-{date}/
├── frames/
│ ├── S_01.png (朝下·站立)
│ ├── S_02.png (朝下·迈步)
│ └── ...
├── sprite_sheet.png
├── preview.gif
└── manifest.json
Switching APIs
User can switch at any time:
python -c "
from sprite_gen.utils.config import set_api_key, set_default_api
set_api_key('<openai|jimeng>', '<NEW_KEY>')
set_default_api('<openai|jimeng>')
"
Notes
- API keys are stored in
~/.claude/sprite-gen-config.json— never committed to git - Add
sprites/to.gitignore - 即梦 endpoint in
adapters/jimeng.pyis a placeholder — confirm against actual API docs