Add score-based transitions and fix mode switching to prevent cascading and visual glitches

This commit is contained in:
2025-11-04 21:15:58 +00:00
parent 598c39e24a
commit 62c0eb8b71
4 changed files with 69 additions and 14 deletions
+1
View File
@@ -135,6 +135,7 @@ export type GameStatusManager = {
setGameLoopCallback: (callback: (deltaTime: number, letters: FallingLetter[]) => void) => void;
setGameMode: (mode: GameMode) => void;
setPendingOptions: (options: GameOptions) => void;
hasPendingOptions: () => boolean;
addCorrect: () => void;
addMissed: () => void;
addDeath: () => void;
+6 -6
View File
@@ -333,12 +333,7 @@ export function useGameStatus(_onGameLoopTick?: (deltaTime: number, letters: Fal
const setPendingOptions = (newOptions: GameOptions) => {
pendingOptionsRef.current = newOptions;
// Update currentGameMode immediately so getCurrentCount() returns the correct value
if (newOptions.gameMode) {
setCurrentGameMode(newOptions.gameMode);
gameModeRef.current = newOptions.gameMode;
}
// Don't update anything immediately - wait for applyPendingOptions
};
const applyPendingOptions = () => {
@@ -404,6 +399,10 @@ export function useGameStatus(_onGameLoopTick?: (deltaTime: number, letters: Fal
return 0;
};
const hasPendingOptions = () => {
return pendingOptionsRef.current !== null;
};
return {
gameStatus,
setGameStatus,
@@ -416,6 +415,7 @@ export function useGameStatus(_onGameLoopTick?: (deltaTime: number, letters: Fal
setGameLoopCallback,
setGameMode,
setPendingOptions,
hasPendingOptions,
addCorrect,
addMissed,
addDeath,