Skip to content

Commit 0aa4561

Browse files
Fix: fixed error messages in lesson 20 part 2 (#1146)
* Fix: Fixed incorrect error messages in lesson 20 * Fix: Fixed lesson 20 error messages * c --------- Co-authored-by: Nathan Lovato <12694995+NathanLovato@users.noreply.github.com>
1 parent 595f8d8 commit 0aa4561

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

game_demos/DrawingTurtle.gd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ func move_forward(distance: float) -> void:
5959
previous_point = _points[-1]
6060
var new_point := previous_point + Vector2.RIGHT.rotated(deg2rad(turn_degrees)) * distance
6161
new_point = new_point.snapped(Vector2.ONE)
62+
var is_closed := false
63+
# Consider the polygon closed if a coordinate is repeated.
64+
if new_point in _points:
65+
is_closed = true
6266
_points.append(new_point)
63-
6467
_temp_command_stack.append(
6568
{command = "move_to", target = new_point + position + _current_offset}
6669
)
70+
if is_closed:
71+
_close_polygon()
6772

6873

6974
func turn_right(angle_degrees: float) -> void:

0 commit comments

Comments
 (0)