Skip to main content
← All Posts

A spritesheet workshop for TileForge

The three jobs I used to do in other programs before importing anything into TileForge now sit next to the editor.

A batch resizer that resizes, trims and chroma-keys a pile of images in one go. A slicer that cuts a sheet on a grid and gives you a scrubbable animation preview, so you can check your frames actually animate before you commit to the slicing. And a stitcher that packs loose images into a sheet with extrusion — the padding that stops neighbouring pixels bleeding in and making your tilemap show seams.

They run in a pop-out window that talks to the main editor, which keeps the editor’s own surface from growing a third toolbar.

Extrusion is the one I’d highlight. Seam bleeding is the single most common reason a tilemap looks subtly wrong in an engine but fine in your art program, and it’s invisible until you zoom or scroll. Having the fix at pack time rather than as something you remember to do is worth more than it sounds.

The bug class I now design against

The other half of the month went on a reliability problem, and it’s worth writing up because the shape of it keeps recurring.

TileForge lets you work offline, queuing edits and uploading them when you’re back. The upload function returned null when it failed — expired token, bad response, network error, all of them null rather than an exception.

And the code handling the queue treated that as success.

There was retry logic sitting right there: try three times, then warn. It was unreachable, because the only way to get to it was an exception and the function had been written to never throw one. Good error handling, dead on arrival, for precisely the case it existed for.

The fix is one line of consequence — make a null result throw — and the retry path that was already correct started working immediately. The queue is backed by that path now and the state it reports is derived from whether the upload actually completed.

What I took from it: returning null instead of throwing feels defensive, and it is, but it only defends the function. It hands the entire job of noticing to a caller that has no way to tell “nothing to do” apart from “this failed.” One value, two meanings. I’ve hit that shape enough times this year that it’s now something I look for on review rather than something I discover.

Maps that imported as blank

A smaller one with the same flavour. Importing a Tiled map that uses the infinite-map format gave you a blank map and no error.

My parser read the layer’s data field, and infinite maps don’t keep their data there — it lives in chunks. So the parser found nothing, imported nothing, reported success, and handed you an empty grid. Anyone hitting that would reasonably conclude TileForge couldn’t read their file, which was true, and for no reason they could see.

Underneath

A 1,098-line panel became a 306-line orchestrator plus two modules. Four seams got centralised — the engine registry, the tool manifest, the editor state schema and zone resolution — each landing as its own increment with the architecture document updated in the same change.

On the security side, API keys and access tokens moved out of local storage into memory only, and a per-user coordination object now handles storage quota atomically, closing a gap in the old reserve-then-commit flow. That second one is in the repo and deliberately not deployed yet: it introduces a one-way migration and a new dependency on the write path, and that deserves its own sitting rather than being tacked onto the end of a busy month.

The suite went 529 to 685 over the month, including the first coverage the canvas layer has ever had — 53 tests across the compositor, the map canvas and the grid renderer. The coverage thresholds sit at the current floor minus a margin rather than at an aspirational number, because a gate you keep lowering isn’t a gate.

— Bruno