Atrament Web
Atrament Web is a ready-to-use build of Atrament Core for the web browser. It is bundled with a specific set of interface implementations:
- loader: fetch + fflate
- persistent: localForage / Neutralinojs storage
- state: nanostores
- sound: howler.js
- platform: web / Neutralinojs
The library detects the environment to define which interface to use for persistent storage and platform features.
Usage
Initialization and game start:
import atrament from '@atrament/web';
atrament.init({
applicationID: 'your-application-id',
settings: {}
});
await atrament.game.init('/path/to', 'inkfile.ink.json');
await atrament.game.start();
atrament.game.continueStory();
State in components:
import { useStore } from '@nanostores/preact';
const gameState = useStore(atrament.store);
Loading progress tracking
In addition to standard loader methods, Atrament Web provides an onProgress handler to track download progress:
function progressTracker({ percent, receivedLength, totalLength}) {
console.log(`Downloaded ${receivedLength} out of ${totalLength} (${percent})%`);
}
atrament.interfaces.loader.onProgress(progressTracker);
await atrament.game.init('/path/to', 'inkfile.ink.json');