Skill: Share the game
Build the finished game into a folder of plain files and put it online so other people can play. Use when the user wants to publish, deploy, or host the...
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.
npm run dev runs the game on your own computer while you make it. To let other people play, you make a "production
build" - a folder of plain files - and upload that folder to a free hosting site. The game is just files, so there is no
server or database to set up.
When to use
Use when the user wants to publish, deploy, or host the game, send a playable link to a friend, or asks "how do I put my game online" or "make a real version".
Step 1: build the game
npm run buildThis writes a dist/ folder. Everything the game needs is inside it: the HTML page, the JavaScript, and your sprites
and fonts. That whole folder is the game.
Step 2: try the built game before sharing
The built game can behave a little differently from the dev server, so test it once first. Your project has a preview
script for this - run it the same way you run dev and build (for example pnpm run preview or npm run preview).
It serves the dist/ folder at a local web address so you can click around and confirm everything still works.
Step 3: put dist/ online
Upload the whole dist/ folder to any free static host - it accepts plain files, no server needed. Good options for a
game are GitHub Pages, Netlify, Cloudflare Pages, or itch.io (drag-and-drop the folder). Each one gives you back a web
address you can share.
Notes
- The game runs on WebGPU where it is available and falls back to plain Canvas 2D everywhere else, so friends can play in any modern browser with nothing extra installed. (Only fullscreen CRT or post-process effects need WebGPU - see the add-crt-effect skill.)
- Has sound? Expect the shared game to be silent until the player clicks, taps, or presses a key. Browsers refuse to make noise on a page nobody has touched yet, so this is not a broken upload. Give the game a "press a key to start" screen and the sound arrives with the first keypress. See the play-a-sound skill.
- Played on a phone? Mobile browsers dim and then lock the screen after 30-60 seconds of no touches, even mid-game. Set
isWakeLockEnabled: trueinconfigure()to keep the screen awake during active play. Landscape-only games can also setpreferredOrientation: 'landscape'(Android may lock; iOS will not) and readBT.screenOrientationor implementonOrientationChange(type)to show a "please rotate" prompt. See the blit-api-names rule for the exact names. - Made a change you want to share? Run
npm run buildagain and re-uploaddist/. The build does not update itself. - Do not hand-edit files inside
dist/- they are generated from yoursrc/code. Change the source, then rebuild.
Skill: Scroll with a camera
Scroll a world larger than the screen using the global camera offset and keep it clamped inside the world bounds. Use for side-scrollers, top-down maps, or...
Skill: Show a loading screen
Show a loading spinner or progress UI while sprites and audio finish loading, using BT.loadingAssetsCount and optional SpriteSheet.status / progress. Use...