feat: Implement core player movement, input, and player scene setup, including grid-based movement, rotation, push mechanics, and multiplayer synchronization.

This commit is contained in:
Yogi Wiguna
2026-03-04 12:33:06 +08:00
parent 8b33ed3f56
commit b32565203f
3 changed files with 161 additions and 61 deletions
+23 -18
View File
@@ -18,24 +18,20 @@ func _process(delta):
return
# Continuous movement input
var target_position = player.current_position
var move_vec = Vector2i.ZERO
if Input.is_action_pressed("move_north"): move_vec.y -= 1
if Input.is_action_pressed("move_south"): move_vec.y += 1
if Input.is_action_pressed("move_east"): move_vec.x += 1
if Input.is_action_pressed("move_west"): move_vec.x -= 1
if Input.is_action_pressed("move_north"):
target_position += Vector2i(0, -1)
elif Input.is_action_pressed("move_northeast"):
target_position += Vector2i(1, -1)
elif Input.is_action_pressed("move_east"):
target_position += Vector2i(1, 0)
elif Input.is_action_pressed("move_southeast"):
target_position += Vector2i(1, 1)
elif Input.is_action_pressed("move_south"):
target_position += Vector2i(0, 1)
elif Input.is_action_pressed("move_southwest"):
target_position += Vector2i(-1, 1)
elif Input.is_action_pressed("move_west"):
target_position += Vector2i(-1, 0)
elif Input.is_action_pressed("move_northwest"):
target_position += Vector2i(-1, -1)
# Fallback for explicit diagonal actions (if mapped)
if move_vec == Vector2i.ZERO:
if Input.is_action_pressed("move_northeast"): move_vec = Vector2i(1, -1)
elif Input.is_action_pressed("move_southeast"): move_vec = Vector2i(1, 1)
elif Input.is_action_pressed("move_southwest"): move_vec = Vector2i(-1, 1)
elif Input.is_action_pressed("move_northwest"): move_vec = Vector2i(-1, -1)
# Action inputs (still momentary)
if Input.is_action_just_pressed("action_grab"):
@@ -43,7 +39,16 @@ func _process(delta):
elif Input.is_action_just_pressed("action_put"):
player.auto_put_item()
if target_position != player.current_position:
if move_vec != Vector2i.ZERO:
# Calculate target relative to intent (future position) to prevent zigzagging
var reference_pos = player.current_position
if movement_manager.is_moving:
if not movement_manager.movement_queue.is_empty():
reference_pos = movement_manager.movement_queue[-1]
elif player.target_position != Vector2i(-1, -1):
reference_pos = player.target_position
var target_position = reference_pos + move_vec
movement_manager.simple_move_to(target_position)