feat: add maxLevel to GameOptions with default of 25

- New option: maxLevel (defaults to 25)
- Once a player reaches maxLevel, levels no longer progress
- Prevents unlimited level scaling and FPS increases
- Example: useGame({ maxLevel: 10 })
This commit is contained in:
2025-10-31 00:28:29 +00:00
parent 520a640ea0
commit b82bef56e5
4 changed files with 10 additions and 6 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import { useKeyBindings, type UseKeyBindingsType } from "./useKeyBindings";
import { useScore } from "../useScore";
export function useGame(options?: GameOptions, platformHook?: unknown): GameManager {
const { cols = 30, rows = 20, startingLevel, foodsPerLevel } = options ?? {};
const { cols = 30, rows = 20, startingLevel, foodsPerLevel, maxLevel } = options ?? {};
const boardManager = useBoard();
const { containerRef, renderBoard } = boardManager;
@@ -18,7 +18,7 @@ export function useGame(options?: GameOptions, platformHook?: unknown): GameMana
const foodManager = useFood(cols, rows, boardManager);
const gameManager = useGameStatus(boardManager, snakeManager, foodManager, { startingLevel, foodsPerLevel });
const gameManager = useGameStatus(boardManager, snakeManager, foodManager, { startingLevel, foodsPerLevel, maxLevel });
const { gameStatus, setGameStatus, startGame, quitGame, togglePause, score, level } = gameManager;
useEffect(() => {