fix: preserve gameStatus when switching game modes

- Stop passing gameMode as dependency to useGameStatus initialization
- Create useGameStatus once with default 'letters' mode
- Add setGameMode method to update mode via ref without recreating hook
- Update gameMode via effect in useGame when it changes
- Fixes issue where switching to letters mode and starting game would reset to waiting
This commit is contained in:
2025-11-03 23:41:12 +00:00
parent 662557c933
commit 308eafac62
3 changed files with 12 additions and 1 deletions
+1
View File
@@ -107,6 +107,7 @@ export type GameStatusManager = {
updatePlayerX: (x: number) => void;
handleTypedLetter: (letter: string) => void;
setGameLoopCallback: (callback: (deltaTime: number, letters: FallingLetter[]) => void) => void;
setGameMode: (mode: GameMode) => void;
addCorrect: () => void;
addMissed: () => void;
addDeath: () => void;