diff --git a/Characters/Player.gd b/Characters/Player.gd index ec026cc..3e64f73 100644 --- a/Characters/Player.gd +++ b/Characters/Player.gd @@ -1,3 +1,17 @@ extends Node2D -export var starting_pos : Vector2 = Vector2.ZERO +export var map_position : Vector2 = Vector2.ZERO + +var target_position : Vector2 = Vector2.ZERO +var moving : bool = false + + +func _physics_process(delta): + + # If the 2 positions are close enough, then not moving + moving = false if target_position.round() == position.round() else true + + if not moving: return + + #TODO: Replace with tween magic + position += (target_position - position)/2.5 diff --git a/Scenes/BattleScene.gd b/Scenes/BattleScene.gd index ae3facf..fbeb350 100644 --- a/Scenes/BattleScene.gd +++ b/Scenes/BattleScene.gd @@ -25,5 +25,11 @@ func _physics_process(delta): if movement_queue.find(Vector2.ZERO) != -1: movement_queue.remove(movement_queue.find(Vector2.ZERO)) + if len(movement_queue) == 0: + return - + #move the character once space in the queue if not moving + if not $Player.moving: + $Player.map_position += movement_queue.pop_front() + $Player.target_position = $TileMap.map_to_world($Player.map_position) + $Player.target_position += $TileMap.cell_size/2