Skip to content

Commit ff2c055

Browse files
author
James Brundage
committed
feat: Turtle.get/set_IsPenUp ( Fixes #45 )
Also updating Forward to respect this setting
1 parent d4e9e7d commit ff2c055

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Types/Turtle/Forward.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@ $Distance = 10
66
$x = $Distance * [math]::round([math]::cos($this.Heading * [Math]::PI / 180),15)
77
$y = $Distance * [math]::round([math]::sin($this.Heading * [Math]::PI / 180),15)
88
$this.Position = $x, $y
9-
$this.Steps += "l $x $y"
9+
if ($This.IsPenDown) {
10+
$this.Steps += " l $x $y"
11+
} else {
12+
$this.Steps += " m $x $y"
13+
}
1014
return $this

Types/Turtle/get_IsPenDown.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if ($null -ne $this.'.IsPenDown') { return $this.'.IsPenDown' }
2+
return $true

Types/Turtle/set_IsPenDown.ps1

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
param(
2+
[bool]
3+
$IsDown
4+
)
5+
6+
$this |
7+
Add-Member -MemberType NoteProperty -Force -Name '.IsPenDown' -Value $IsDown
8+
9+
if ($VerbosePreference -ne 'SilentlyContinue') {
10+
Write-Verbose "Turtle is now $($IsDown ? 'down' : 'up')"
11+
}

0 commit comments

Comments
 (0)