feat(web): implement game lifecycle management for SPA navigation

Add stop_game and restart_game FFI functions to properly pause/resume the game loop during page transitions, preventing resource leaks and audio issues when navigating between pages
This commit is contained in:
2025-12-29 02:06:15 -06:00
parent 791a0e48e3
commit 5e86bbb040
7 changed files with 148 additions and 26 deletions
+16
View File
@@ -0,0 +1,16 @@
export interface PacmanModule {
canvas: HTMLCanvasElement;
_start_game?: () => void;
_stop_game?: () => void;
_restart_game?: () => void;
locateFile: (path: string) => string;
preRun: unknown[];
}
export interface PacmanWindow extends Window {
Module?: PacmanModule;
pacmanReady?: () => void;
SDL_CANVAS_ID?: string;
}
export const getPacmanWindow = (): PacmanWindow => window as unknown as PacmanWindow;