From 9b4fab0071140356c0156c29a82c7b1bcb1eb525 Mon Sep 17 00:00:00 2001 From: "Z. Cliffe Schreuders" Date: Sat, 8 Nov 2025 16:01:19 +0000 Subject: [PATCH] Refactor player movement logic to prioritize keyboard input and add idle animation state --- js/core/player.js | 12 +++++++++--- scenarios/npc-sprite-test2.json | 8 ++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/js/core/player.js b/js/core/player.js index d7ce6d1..7f90f28 100644 --- a/js/core/player.js +++ b/js/core/player.js @@ -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() { diff --git a/scenarios/npc-sprite-test2.json b/scenarios/npc-sprite-test2.json index b3d058d..099523e 100644 --- a/scenarios/npc-sprite-test2.json +++ b/scenarios/npc-sprite-test2.json @@ -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" } ] }