adding turtle examples (#598)

This commit is contained in:
Peli de Halleux 2017-12-08 14:56:39 -08:00 committed by GitHub
parent 862bd64acc
commit 81e804c1e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 84 additions and 0 deletions

View File

@ -68,6 +68,27 @@ Here are some fun programs for your @boardname@!
}] }]
``` ```
## Turtle graphics
```codecard
[{
"name": "Turtle Square",
"description": "move in a square",
"url":"/examples/turtle-square",
"cardType": "example"
}, {
"name": "Turtle Spiral",
"description": "move in a spiral",
"url":"/examples/turtle-spiral",
"cardType": "example"
}, {
"name": "Turtle Scanner",
"description": "scans the screen down",
"url":"/examples/turtle-scanner",
"cardType": "example"
}]
```
## Actuators ## Actuators
```codecard ```codecard

View File

@ -0,0 +1,23 @@
# Turtle Scanner
The turtle keeps on the scanning the screen.
```blocks
turtle.setPosition(0, 0)
turtle.turnRight()
turtle.setSpeed(20)
basic.forever(() => {
turtle.forward(4)
turtle.turnRight()
turtle.forward(1)
turtle.turnRight()
turtle.forward(4)
turtle.turnLeft()
turtle.forward(1)
turtle.turnLeft()
})
```
```package
microturtle=github:Microsoft/pxt-microturtle#master
```

View File

@ -0,0 +1,23 @@
# Turtle Spiral
The turtle goes to the center back and forth.
```blocks
let index = 0
turtle.setPosition(0, 0)
turtle.turnRight()
basic.forever(() => {
for (let index = 0; index <= 4; index++) {
turtle.forward(4 - index)
turtle.turnRight()
}
for (let index = 0; index <= 4; index++) {
turtle.turnLeft()
turtle.back(index)
}
})
```
```package
microturtle=github:Microsoft/pxt-microturtle#master
```

View File

@ -0,0 +1,17 @@
# Turtle Square
A turtle program that runs in a square.
```blocks
turtle.setPosition(0, 0)
turtle.turnRight()
turtle.setSpeed(29)
basic.forever(() => {
turtle.forward(4)
turtle.turnRight()
})
```
```package
microturtle=github:Microsoft/pxt-microturtle#master
```