diff --git a/example/src/App.tsx b/example/src/App.tsx index fc6b80a..f787f3a 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -1,9 +1,12 @@ +import { useState } from "react"; import { useGame } from "../../src/useGame"; import { useKeyBindings } from "./useKeyBindings"; +import type { Difficulty } from "../../src/types"; import '../../src/game.css'; function App() { - const gameManager = useGame({ difficulty: 'medium' }, useKeyBindings); + const [difficulty, setDifficulty] = useState('medium'); + const gameManager = useGame({ difficulty }, useKeyBindings); const { containerRef, gameStatus, scoreManager } = gameManager; const { timeValue, keystrokes, finalScore } = scoreManager; @@ -17,6 +20,50 @@ function App() { return (

VIMazing vim-sudoku example

+ + {gameStatus === "waiting" && ( +
+
+
Select Difficulty
+
+ + + +
+
+
+ )} +
{(gameStatus === "started" || gameStatus === "game-won") && (
diff --git a/src/useGame.ts b/src/useGame.ts index 941533d..4fe9c94 100644 --- a/src/useGame.ts +++ b/src/useGame.ts @@ -21,7 +21,7 @@ export function useGame(options: GameOptions = {}, platformHook?: unknown): Game } else if (gameStatus === 'waiting') { renderBoard(); } - }, [gameStatus]); + }, [gameStatus, difficulty]); const gameManager: GameManager = { containerRef,