proper keybindings

This commit is contained in:
2025-10-16 13:21:22 +01:00
parent 6a3cfad409
commit 20ac6b9349
6 changed files with 127 additions and 39 deletions
+4 -2
View File
@@ -3,6 +3,7 @@ import { useRenderer } from "./useRenderer";
import { useSnake } from "./useSnake";
import { useGameStatus } from "./useGameStatus";
import { useKeyBindings, type UseKeyBindingsType } from "./useKeyBindings";
import { useScore } from "../useScore";
export function useGame(cols: number, rows: number, platformHook?: unknown) {
const rendererManager = useRenderer();
@@ -21,12 +22,12 @@ export function useGame(cols: number, rows: number, platformHook?: unknown) {
const keyBindings: UseKeyBindingsType = useKeyBindings({
gameManager: {
gameStatus,
startGame,
stopGame,
changeDirection,
},
});
const scoreManager = useScore({ gameStatus });
const fullGameManager = {
containerRef,
gameStatus,
@@ -34,6 +35,7 @@ export function useGame(cols: number, rows: number, platformHook?: unknown) {
stopGame,
...snakeManager,
...keyBindings,
scoreManager,
};
if (typeof platformHook === "function") {