From da8f257636bb5d92354b30c8b12c85f8299eed56 Mon Sep 17 00:00:00 2001 From: KevinKor01 Date: Fri, 4 Jul 2025 14:18:07 +0300 Subject: [PATCH] Cube & Scoring Logic Part 2 Offset : 0-15 basically center (ln 42) and anything else is left right alignment: 0.8-1 good cut 0 basically perpendicular -1 opposite to cut direction --- game/Objects/Cube.gd | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/game/Objects/Cube.gd b/game/Objects/Cube.gd index 57bb636..351461f 100644 --- a/game/Objects/Cube.gd +++ b/game/Objects/Cube.gd @@ -25,18 +25,7 @@ var BotScore = 0 var sliced = false func _ready(): - - - var shape_size = Vector2.ZERO - if shape.shape is RectangleShape2D: - shape_size = shape.shape.extents * 2 # extents are half-size - elif shape.shape is CapsuleShape2D: - shape_size = Vector2(shape.shape.radius * 2, shape.shape.height) - # Add other shape types as needed - - # Now use actual height - var cube_height = shape_size.y - + pass func _on_area_entered(area: Area2D) -> void: if area.name != "Cursor": @@ -47,15 +36,19 @@ func _on_area_entered(area: Area2D) -> void: var local_pos = to_local(area.global_position) - var side_offset = local_pos.y # this is the offset *perpendicular* to Area2D's facing + var side_offset = local_pos.y var alignment = area_direction.dot(body_direction) - if abs(side_offset) < 5: - print("Hit near center Top", " ", alignment) + if abs(side_offset) < 15: + print("Hit near center Slice Side offset:", round(side_offset) ," ", alignment) elif side_offset < 0: print("Hit to the LEFT Side, offset:", side_offset, " ", alignment) else: print("Hit to the RIGHT Side, offset:", side_offset, " ", alignment) + + if alignment > 0.8: + print("Consider Good Cut") + func get_closest_point_on_line(line_origin: Vector2, line_dir: Vector2, point: Vector2) -> Vector2: