#------------------------------------------------------------ # Script: Player Manager # Author: NotDinoBits # Contributers: # # Godot Version: 4.7 # Language: GDScript # # Description: Manages player interaction by listening for # For inputs and providing an interaction interface # # Input reactions change based on what mode the # game is currently in (exploration, combat, menu) #------------------------------------------------------------ extends Node2D var screen_size # Player position on the grid var grid_position: Vector2i = Vector2i(2, 2) # Reference to Board @onready var board = get_node("../Board") func _ready() -> void: screen_size = get_viewport_rect().size global_position = board.get_tile_world_position(grid_position) func _process(_delta: float) -> void: # Exploration mode movement if Input.is_action_just_pressed("hop_right"): move_player(Vector2i.RIGHT) elif Input.is_action_just_pressed("hop_left"): move_player(Vector2i.LEFT) elif Input.is_action_just_pressed("hop_up"): move_player(Vector2i.UP) elif Input.is_action_just_pressed("hop_down"): move_player(Vector2i.DOWN) func move_player(direction: Vector2i) -> void: var target_position: Vector2i = grid_position + direction # Check board boundaries if not board.can_move_to(target_position): return # Update player's grid location grid_position = target_position # Move player to the center of the tile global_position = board.get_tile_world_position(grid_position)