Skill: Update BLIT386 API names
Update a game's code after a BLIT386 upgrade renamed parts of the API, and enable hot reload in vite.config on blit386 1.4.0+. Use this when 'blit upgrade'...
Written for blit386 1.8.0. The rest of blit386.dev documents the newest engine, so an API you find there may be missing from a game pinned to 1.8.0.
Update a game after a BLIT386 upgrade renamed parts of the API: let blit migrate make the safe renames, then handle
the rest by hand.
When to use
Use when blit upgrade or blit migrate reports names that "need a closer look," when the game breaks after a BLIT386
update, or when the user says "update my game to the new version" or "fix the renamed functions."
Steps
- Preview first: run
npx blit migrate. It lists the renames it can make automatically, the ones that need review, and whether it can enable hot reload invite.config(blit386 1.4.0+). Nothing is written yet. - Apply the safe ones: run
npx blit migrate --write. This rewrites unambiguous names for you (for exampleBT.buttonDown->BT.isDown, theoverlayEnabledconfig flag ->isOverlayEnabled) and, when missing, adds theblit386()Vite plugin so code andpublic/asset edits keep the game running. - Handle each "needs a closer look" item by hand. These are common words, so the tool will not rewrite them blindly -
they might belong to your own code. Only rename a call when the value on the left is the matching BLIT386 type:
.equals(...)->.isEqual(...)on aVector2i,Rect2i, orColor32.contains(...)->.isContaining(...)on aRect2i.intersects(...)->.isIntersecting(...)on aRect2i.tick(...)->.fireIfElapsed(...)on aTimer- Inside the
bootstrap(...)options object only:canvasId->canvasID,containerId->containerID,waitForDOMReady->isWaitingForDOMReady
- Leave anything that is not a BLIT386 value alone. A plain array's
.contains(...)or your owntick()method is not the engine - do not touch it. - If migrate could not edit an unusual
vite.config, add hot reload by hand (see the use-hot-reload skill /docs/hot-reload.md), then restartnpx blit runonce. - Verify: run
npx blit runand play the game, ornpx blit doctorto check the setup. If something still breaks, use the "fix" skill.
Notes
- The full, authoritative list of old -> new names is the engine's deprecation timeline: https://blit386.dev/docs/reference/deprecations
- Hot reload enablement needs blit386 1.4.0+. Prefer
npx blit upgradefirst if you are behind - it updates the engine and then offers the same migrate step. blit migratepreviews by default and only changes files with--write, so it is always safe to run and read first.- If the project is not saved with git, save a copy before writing -
blit migrate --writewarns about this first.
Skill: Keep it fast
Find and fix slow frames: stop making new objects every frame, batch sprites by sheet, skip what is off screen, and stay inside the engine's per-frame...
Skill: Move and time things
Move things smoothly and schedule actions using the engine frame clock, the Timer helper, and the easing curve library (`applyEasing`, `interpolate`). Use...