Implement platform-controlled GameOptions for complete game behavior customization
- Add GameOptions with gameMode, downwardSpeed, boardDimensions, and wordList - Platform now controls ALL game behavior through options - changeGameMode now accepts full GameOptions instead of just mode - downwardSpeed as single px/s value applies to any mode - wordList is mode-agnostic, platform provides what they need - All options are fully optional with sensible defaults - Update example app to use new options API
This commit is contained in:
+3
-3
@@ -5,13 +5,13 @@ import { useKeyBindings } from "./useKeyBindings";
|
||||
|
||||
function App() {
|
||||
const [gameMode, setGameMode] = useState<GameMode>("letters");
|
||||
const gameManager = useGame({ initialGameMode: gameMode }, useKeyBindings);
|
||||
const gameManager = useGame({ gameMode }, useKeyBindings);
|
||||
const { containerRef, gameStatus, scoreManager } = gameManager;
|
||||
|
||||
useEffect(() => {
|
||||
if (scoreManager.score === 5 && gameMode === "letters") {
|
||||
setGameMode("words");
|
||||
gameManager.changeGameMode("words");
|
||||
gameManager.changeGameMode({ gameMode: "words" });
|
||||
}
|
||||
}, [scoreManager.score, gameMode, gameManager]);
|
||||
|
||||
@@ -32,7 +32,7 @@ function App() {
|
||||
key={mode}
|
||||
onClick={(e) => {
|
||||
setGameMode(mode);
|
||||
gameManager.changeGameMode(mode);
|
||||
gameManager.changeGameMode({ gameMode: mode });
|
||||
e.currentTarget.blur(); // Remove focus from button
|
||||
}}
|
||||
className={`px-3 py-1 rounded capitalize font-medium transition ${gameMode === mode
|
||||
|
||||
Reference in New Issue
Block a user