A 2D game engine based on the standard Web APIs.
See the examples/
folder for example projects, and go here to play them.
- Initialize a new Vite project. Choose
Vanilla
andTypescript
npm create vite@latest
cd
into the directory- Install web-game-engine
npm i web-game-engine
- Delete
src/counter.ts
andsrc/style.css
. Replace the contents ofsrc/main.ts
with
import { ExamplePlayer, Game, TextObject } from 'web-game-engine';
const game = new Game(document.querySelector('#app'));
new ExamplePlayer(50, 50)
.activate(game);
new TextObject(() => `FPS: ${game.currentFps.toFixed(1)}`, 8, 8)
.activate(game);
game.play();
- Play the game by running in dev mode
npm run dev
- Build, and deploy the
dist
folder
npm run build