@funpixel/sdk
v0.7.0
Published
Funpixel game SDK — host channel (ready/leaderboard/liveParams/gameState), device APIs (haptics/camera/geolocation/sensors/filesystem), assets, audio (iOS-safe), pathfinding, and engine fx for pixi/three, multiplayer (Room API over the relay).
Readme
@funpixel/sdk
The small runtime a browser game uses on Funpixel: talk to the page it plays in, keep scores and saves, play sound that works on phones, and reach the device. Every module works when the game runs on its own too, so the same build plays anywhere.
npm install @funpixel/sdkWhat's in it
| Import | What it does |
|---|---|
| @funpixel/sdk | setupGameResize (fit the canvas to its window or host frame) and markMoment |
| @funpixel/sdk/host | host.ready(): whether the game runs inside Funpixel, and what the host offers |
| @funpixel/sdk/leaderboard | leaderboard(): submit a score to the host's board, and the player's best |
| @funpixel/sdk/save | SaveManager: versioned saves that report when storage fails |
| @funpixel/sdk/gameState · /liveParams | save, load and clear the whole game state; named values a host panel can tune while it plays |
| @funpixel/sdk/audio | AudioEngine: one audio context, unlocked on the first tap, safe on iOS |
| @funpixel/sdk/device | haptics, fullscreen, orientation, motion, safe area, camera, geolocation, sensors |
| @funpixel/sdk/assets | loading the game's assets |
| @funpixel/sdk/pathfinding | grid pathfinding |
| @funpixel/sdk/multiplayer | Room: rooms over Funpixel's relay, with host migration and late-join state |
| @funpixel/sdk/pixi · /three | effects for PixiJS and three.js |
A first look
import { setupGameResize } from '@funpixel/sdk';
import { host } from '@funpixel/sdk/host';
import { AudioEngine } from '@funpixel/sdk/audio';
setupGameResize((width, height) => renderer.resize(width, height));
const audio = new AudioEngine();
button.addEventListener('pointerdown', () => audio.unlock(), { once: true });
const info = await host.ready(); // { host: false } when the game runs on its ownDocs
The API, with examples for every module: docs.funpixel.ai.
To make a whole game with your coding agent, see npx @funpixel/tools setup.
Licence
MIT. See LICENSE.
