pen up/pen down
This commit is contained in:
parent
6e065febaf
commit
5c28ec18e8
1
bun.lock
1
bun.lock
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
|
"configVersion": 0,
|
||||||
"workspaces": {
|
"workspaces": {
|
||||||
"": {
|
"": {
|
||||||
"name": "fin",
|
"name": "fin",
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,14 @@ class Turtle {
|
||||||
turtleCtx.restore()
|
turtleCtx.restore()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pen(dir: string) {
|
||||||
|
switch (dir) {
|
||||||
|
case 'up': this.penup(); break
|
||||||
|
case 'down': this.pendown(); break
|
||||||
|
default: throw "pen only accepts up or down"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
penup() {
|
penup() {
|
||||||
this.penDown = false
|
this.penDown = false
|
||||||
}
|
}
|
||||||
|
|
@ -254,6 +262,7 @@ const globals = {
|
||||||
back: async (n: number) => await turtle.back(n),
|
back: async (n: number) => await turtle.back(n),
|
||||||
left: async (n: number) => await turtle.left(n),
|
left: async (n: number) => await turtle.left(n),
|
||||||
right: async (n: number) => await turtle.right(n),
|
right: async (n: number) => await turtle.right(n),
|
||||||
|
pen: (dir) => turtle.pen(dir),
|
||||||
penup: () => turtle.penup(),
|
penup: () => turtle.penup(),
|
||||||
pendown: () => turtle.pendown(),
|
pendown: () => turtle.pendown(),
|
||||||
setcolor: (n: number) => turtle.setcolor(n),
|
setcolor: (n: number) => turtle.setcolor(n),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user