From 7e12f1dc22da69be5bcb133364c33688a657c2e4 Mon Sep 17 00:00:00 2001 From: 2ManyProjects Date: Sat, 8 Feb 2025 17:01:01 -0600 Subject: [PATCH] cleaned up game tile size ref --- Systems/Game/ChessGame.gd | 1 + addons/Chess/Scripts/Knight.gd | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Systems/Game/ChessGame.gd b/Systems/Game/ChessGame.gd index ec4cb2b..a1da407 100644 --- a/Systems/Game/ChessGame.gd +++ b/Systems/Game/ChessGame.gd @@ -45,6 +45,7 @@ var darkStyle = null var highlightStyle = null func _ready() -> void: + add_to_group("ChessGame") DisplayServer.window_set_size(Vector2i(windowXSize, windowYSize)) initializeGame() initializeTiles() diff --git a/addons/Chess/Scripts/Knight.gd b/addons/Chess/Scripts/Knight.gd index 244ac33..1e90e9f 100644 --- a/addons/Chess/Scripts/Knight.gd +++ b/addons/Chess/Scripts/Knight.gd @@ -97,26 +97,27 @@ func animate_movement(target_position: Vector2, duration: float = 0.5) -> void: var total_delta = target_position - start_pos var mid_pos: Vector2 - var cell_delta_x = int(total_delta.x / 50) - var cell_delta_y = int(total_delta.y / 50) + var game = get_tree().get_first_node_in_group("ChessGame") as ChessGame + var cell_delta_x = int(total_delta.x / game.tileXSize) + var cell_delta_y = int(total_delta.y / game.tileYSize) if abs(cell_delta_x) > abs(cell_delta_y): # Moving more horizontally ([-2, ±1]) mid_pos = Vector2( - start_pos.x + (cell_delta_x * 50), + start_pos.x + (cell_delta_x * game.tileXSize), start_pos.y ) else: # Moving more vertically ([±1, -2]) mid_pos = Vector2( start_pos.x, - start_pos.y + (cell_delta_y * 50) + start_pos.y + (cell_delta_y * game.tileYSize) ) # First move (longer distance) - tween.tween_property(self, "global_position", mid_pos, duration/2) + tween.tween_property(self, "global_position", mid_pos, duration / 3 * 2) # Second move (shorter distance) - tween.tween_property(self, "global_position", target_position, duration/2) + tween.tween_property(self, "global_position", target_position, duration / 3 * 1) await tween.finished z_index = 0 \ No newline at end of file