| Engine | Pico-8 0.2.5+ |
|---|---|
| Language | Lua (Pico-8 dialect) |
| Time to run | ~3 minutes |
| Level | Intermediate — comfortable with pal(), spr() and Pico-8 token budgets |
| Output | One Lua snippet (~80 tokens) |
| Dependencies | None. |
The prompt
Open claude.ai/new, paste, send.
$ Build me a Pico-8 sprite drawing helper with palette swap. // shape - A function spr_swap(n, x, y, swaps) that draws sprite n at (x, y) using a per-call palette remap. - swaps is a table mapping source color to target color, e.g. { [8] = 11, [2] = 3 }. - spr_swap restores the default palette after drawing (pal()). // extras - A flash_white(n, x, y) helper that draws the sprite with all colors mapped to color 7 (white). Uses spr_swap internally. - A predefined PALS table with named team palettes: {red = {[11]=8}, blue = {[11]=12}, gold = {[11]=10}}. // constraints - Token budget: keep the entire helper under 100 tokens. - No globals beyond the function names and the PALS table. - Pure Lua, no Pico-8 SDK extensions. // return format - One .p8 lua block of code with the helpers and the PALS table. - A 3-line example showing how to use it from _draw(). - No prose before or after.
Open in Claude ▸
Run · 3 min
What this gets you
Per-instance recolor without doubling your sprite sheet. The same enemy sprite at three colors (red elites, blue mooks, gold bosses) costs the same tokens as one. The flash-white-on-hit gives you "got hit" feel for free.
Quick checklist
- pal() reset after drawing. Without the reset, the next sprite draw inherits the swap. Easy to miss in code review.
- Iterates only over the swap table. Don't loop 0..15 — token cost matters.
- flash_white reuses spr_swap. Don't write a second drawing function; just build a 16-entry table where every color maps to 7.
Full breakdown coming soon
The deeper writeup with actual token counts, hit-flash timing, and screen-shake combo is on the roadmap. Bookmark this page for the heads-up.