player moving, hjkl and counts... anchors not working yet

This commit is contained in:
2025-10-19 13:32:01 +01:00
parent 70a8167fb0
commit b6f5d7ae9f
2 changed files with 4 additions and 5 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ export const useGameKeys = (props: UseGameKeysParams) => {
window.addEventListener("keydown", handler); window.addEventListener("keydown", handler);
return () => window.removeEventListener("keydown", handler); return () => window.removeEventListener("keydown", handler);
}, [gameStatus]); }, [gameStatus, cursor, hero]);
return { return {
keyLog, keyLog,
+3 -4
View File
@@ -39,7 +39,7 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage
function moveTo(coord: Coord): void { function moveTo(coord: Coord): void {
if (!heroPos || !canMoveTo(coord)) return; if (!heroPos || !canMoveTo(coord)) return;
if (gameStatus !== "started" && gameStatus !== "has-key") return; // Note: gameStatus check will be done in moveHero
if (animation.isAnimating()) return; if (animation.isAnimating()) return;
const m = mazeRef.current; const m = mazeRef.current;
@@ -114,6 +114,8 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage
currentSetGameStatus: (s: GameStatus) => void currentSetGameStatus: (s: GameStatus) => void
) { ) {
if (!heroPos) return; if (!heroPos) return;
if (currentGameStatus !== "started" && currentGameStatus !== "has-key") return;
if (animation.isAnimating()) return;
const n = Math.max(1, steps ?? 1); const n = Math.max(1, steps ?? 1);
const targetCoord = { const targetCoord = {
@@ -126,9 +128,6 @@ export function useHero(board: BoardManager, gameStatusManager: GameStatusManage
return; return;
} }
if (currentGameStatus !== "started" && currentGameStatus !== "has-key") return;
if (animation.isAnimating()) return;
const m = mazeRef.current; const m = mazeRef.current;
if (!m.length) return; if (!m.length) return;