import type { Game, World } from "../types"; import { clone } from "../utils"; export class GameFactory { public static create(world: World): Game { return { paused: false, time: 0, scene: clone(world.initialScene), } } public static load(): Game | undefined { const json = localStorage.getItem("game"); if (json) { return JSON.parse(json) as Game; } } public static save(game: Game): void { localStorage.setItem("game", JSON.stringify(game)); } }