Skip to content

Commit

Permalink
improvement: make the turtle start with an offset position in lesson 4
Browse files Browse the repository at this point in the history
closes #105
  • Loading branch information
NathanLovato committed Jan 5, 2022
1 parent 44ceafb commit 64fb16e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@ var length := 200

onready var _turtle: DrawingTurtle = $DrawingTurtle

func _ready() -> void:
reset()

func reset():
_turtle.position.x = -length / 2.0


func run() -> void:
_turtle.reset()
_turtle.position = Vector2.ZERO
_turtle.move_forward(length)

_turtle.play_draw_animation()

var rect := _turtle.get_rect()
_turtle.position = -rect.size / 2.0
"

[node name="ExampleMoveForward" type="PanelContainer"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@ var size := Vector2(200, 120)

onready var _turtle: DrawingTurtle = $DrawingTurtle

func _ready() -> void:
reset()

func reset():
_turtle.position = -size / 2


func run() -> void:
_turtle.reset()
_turtle.position = Vector2.ZERO
_turtle.move_forward(size.x)
_turtle.turn_right(turn)
_turtle.move_forward(size.y)
Expand All @@ -24,8 +29,6 @@ func run() -> void:
_turtle.move_forward(size.y)
_turtle.play_draw_animation()

var rect := _turtle.get_rect()
_turtle.position = -rect.size / 2.0
"

[node name="ExampleRectangle" type="PanelContainer"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ onready var _turtle: DrawingTurtle = $DrawingTurtle

func _ready() -> void:
_turtle.line_draw_speed = 200.0
reset()

func reset():
_turtle.position = -Vector2(217, 57) / 2

func run() -> void:
_turtle.reset()
_turtle.position = Vector2.ZERO
_turtle.move_forward(length)
_turtle.turn_right(turn)
_turtle.move_forward(length)
_turtle.turn_left(turn)
_turtle.move_forward(length)
_turtle.play_draw_animation()

var rect := _turtle.get_rect()
_turtle.position = -rect.size / 2.0
"

[node name="ExampleRotate" type="PanelContainer"]
Expand Down

0 comments on commit 64fb16e

Please sign in to comment.