Here are all the logo commands you can see in the panel on the right. If you need to put some things after the command, they are numbers n
, angles a
, logo colour names c
, words "w
, or lists [...]
.
forward
pd
), a line will be drawn as it moves.fd 10
move forwards 10 units.backward
pd
), a line will be drawn in the current colour (see setpc
).bk 10
move backwards 10 units.right
rt 90
will make a quarter turn to the right. The turtle will turn, or rotate, in place, it will not move across the screen.rt 30
turn right by 30˚. rt 360/3
turn right one third of a full turn (120˚).left
lt 30+10
turn left by 40˚.penup
pendown
setpencolor
(US spelling)setpc 4 fd 5
or setpc red fd 4
0 black | 1 blue | 2 green | 3 cyan |
4 red | 5 magenta | 6 yellow | 7 white |
8 brown | 9 tan | 10 green | 11 aqua |
12 salmon | 13 purple | 14 orange | 15 grey |
setpc "MediumOrchid fd 4
setpc "#6a5acd fd 4
setpensize
setps 1 setpc 1 fd 2
draws a short thin blue line.say "Hello
wait 4
play [ G G G A G G D ]
These commands aren’t in the panel. Try them out anyway.
(0, 0)
at the top left to (1489, 855)
at the bottom right. Each square on the grid is 50 pixels.setxy 100 100 rpt 4 [ fd 2 lt 90 ]
draws a square at the top left of the screen.rt
and lt
, setheading
takes no notice of where the turtle is already pointing. In addition, the turtle does not actually turn until just before the next drawing command is obeyed. This can be confusing when you are debugging!setxy 10 10 setheading 90
goes to (10,10) and turns to point directly to the right.rpt 200 [ setxy random 1489 random 855 rpt 4 [ fd 1 rt 90 ] ]
draws 200 small squares at random positions on the screen.setps 1 rpt 1000 [ fd .5 rt random 360 ]
generates a random walk. Do you think 1000 repeats will see the turtle go off the screen?:name
.rpt 150 [
make "length random 5
make "colour random 15
if (:colour <> 7) [ ; no white squares
setps 5 + random 21 ; pen size between 5 and 20
setpc :colour
setxy random 1489 random 855
rpt 4 [ fd 1+:length rt 90 ]
]
]
Try adding setheading random 90
before the rpt 4
line.
repcount
counts up each time around the loop. So if you do rpt 3 [ say repcount]
, you will see 1, 2, 3 written down the screen.