srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/game.js
blob: 2e8681c9b40e4dc2b7b016269786a44ac8fe7c42 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import init, { TyperPunkGame } from '../wasm/typerpunk_wasm.js';

const ready = init();

export async function createGame() {
    await ready;
    return new TyperPunkGame('');
}

export function freeGame(game) {
    if (!game) return;
    try {
        game.free();
    } catch (err) {
        console.error('Error freeing game:', err);
    }
}