Three games. One API.

Snake, Pong and Breakout built on the same base class. Each one starts, stops, pauses, resumes, mutes and reports its own state through identical method names, and each one emits the same events — so you instrument one game and you have instrumented all of them. Everything below is the real library: play all three, retheme them, and watch the events come off.

npm install @minigame/core @minigame/snake
See the integration code React version

Playground

Three instances, one config object per instance, one control bar each. Change a value in the panel and the games rebuild with it.

Event stream

Every on() subscription in this page writes here. This is the whole analytics story: a game start, each score change, and how the round ended.

0 events

getGameState()

Sampled four times a second. Each game returns its own shape, typed by the same generic base class. The library exposes no lifecycle getter, so the status chip on each card is inferred from the events above.

Drop it into a page

The three games differ in exactly one line: which class you construct. Pong takes an optional third argument, 'pvai' or 'pvp'.

Snake integration