From e253a6b51d2f666abdc94bb80ec69a7194b494fd Mon Sep 17 00:00:00 2001 From: Andre Padez Date: Sun, 19 Oct 2025 02:00:22 +0100 Subject: [PATCH] start and quit game working --- example/src/useKeyBindings.ts | 14 ++++++++------ src/useBoard/useBoard.ts | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/example/src/useKeyBindings.ts b/example/src/useKeyBindings.ts index c96f13f..9212f24 100644 --- a/example/src/useKeyBindings.ts +++ b/example/src/useKeyBindings.ts @@ -1,8 +1,10 @@ import { useEffect } from "react"; -import type { UseGameType } from "@vimazing/vim-maze"; +import type { GameManager } from "../../src"; + +export const useKeyBindings = (gameManager: GameManager) => { + const { gameStatus, startGame, quitGame, keyManager } = gameManager; + const { clearLog } = keyManager; -export const useKeyBindings = (gameManager: UseGameType) => { - const { gameStatus, startGame, stopGame, clearLog } = gameManager; console.log('gameStatus', gameStatus); useEffect(() => { @@ -12,7 +14,7 @@ export const useKeyBindings = (gameManager: UseGameType) => { if (["waiting", "game-over", "game-won"].includes(gameStatus)) { clearLog(); if (gameStatus === "game-over" || gameStatus === "game-won") { - stopGame(); + quitGame(); setTimeout(() => startGame(), 0); } else { startGame(); @@ -26,13 +28,13 @@ export const useKeyBindings = (gameManager: UseGameType) => { // cancel count or stop game if (e.key === "Escape") { - stopGame(); + quitGame(); return; } // quit if (e.key === "q" || e.key === "Q") { - stopGame(); + quitGame(); return; } }; diff --git a/src/useBoard/useBoard.ts b/src/useBoard/useBoard.ts index 4ad2ea6..a57f049 100644 --- a/src/useBoard/useBoard.ts +++ b/src/useBoard/useBoard.ts @@ -1,5 +1,4 @@ import { useEffect, useRef } from "react"; -import type { RefObject } from 'react'; import { MazeGenerator } from "./MazeGenerator"; import { MazeRenderer } from "./MazeRenderer"; import type { MazeCell } from "../types";