Refactor player movement logic to prioritize keyboard input and add idle animation state

This commit is contained in:
Z. Cliffe Schreuders
2025-11-08 16:01:19 +00:00
parent cb95a857fd
commit 9b4fab0071
2 changed files with 17 additions and 3 deletions

View File

@@ -416,11 +416,17 @@ export function updatePlayerMovement() {
// Handle keyboard movement (takes priority over mouse movement)
if (isKeyboardMoving) {
updatePlayerKeyboardMovement();
return;
} else {
// Handle mouse-based movement (original behavior)
updatePlayerMouseMovement();
}
// Handle mouse-based movement (original behavior)
updatePlayerMouseMovement();
// Final check: if velocity is 0 and player is marked as moving, switch to idle
if (player.body.velocity.x === 0 && player.body.velocity.y === 0 && player.isMoving) {
player.isMoving = false;
const animDir = getAnimationKey(player.direction);
player.anims.play(`idle-${animDir}`, true);
}
}
function updatePlayerKeyboardMovement() {

View File

@@ -114,6 +114,14 @@
"name": "Security Keycard",
"takeable": true,
"observations": "Electronic access keycard"
},
{
"type": "notes",
"name": "Security Log",
"takeable": true,
"readable": true,
"text": "Unusual after-hours access detected:\n- CEO office: 11:30 PM\n- Server room: 2:15 AM\n- CEO office again: 3:45 AM",
"observations": "A concerning security log from last night"
}
]
}