player moving, hjkl and counts... anchors not working yet
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user