@antha/fps
v0.4.3
Published
An Antha mod for rendering FPS.
Readme
@antha/fps
This package provides a pre-built Antha game engine mod that displays the engine's current frames per second in the top-left corner of the page.
Install
npm i @antha/fpsUsage
import {AnthaEngine, defineAnthaMod} from '@antha/engine';
import {createAnthaFpsMod, type ShowCountersState} from '@antha/fps';
type GameState = ShowCountersState & {
hasFpsStutter: boolean;
};
const engine = new AnthaEngine<GameState>({
initState: {
hasFpsStutter: false,
},
mods: [
createAnthaFpsMod({
debugFps: true,
}),
defineAnthaMod<GameState>({
modName: 'game-logic',
execute({state}) {
state.hasFpsStutter = !!state.fpsStutters?.length;
return state.hasFpsStutter ? 'Frame rate is low.' : undefined;
},
}),
],
});
engine.startLoop();