Add score-based transitions and fix mode switching to prevent cascading and visual glitches
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user