Loopsie allows you to quickly build and prototype simple games, by providing both a game loop and a simple state management system.
It does not have any opinion in regards to the visual output. Instead, clients can subscribe to state changes and handle them however they see fit.
Loopsie can be used in both node and the browser. It also is fully TypeScript typed.
To install Loopsie, simply add it using your package manager of choice:
npm install loopsie
yarn add loopsie
Your first game loop
;const initialState =score: 0height: 100const gameLoop = intialStatemsPerUdate: 10 // How often new state should be calculatedmaxFPS: 30 // How often subscribers are notifified of latest state// Reduces height by 10 and increases the score by 1, spread over 1 second.// Called continously until loop is stopped.// `delta` indicates how many ms have passed since last callgameLoopgameLoop// On every click, we want to increase the height by 3.// `addRunOnce` is executed during the next loopwindow// Start the loopgameLoopstart;