游乐天地

TurtleAcademy learn programming for freeYour browser is not supporting canvas We recomand you to use Chrome or Firefox browsers

In order to save your program please 登录 报名

海龟动态

向前 X , 前 X

海龟向前移动x个点的距离

例如::

向前 50

课程里的解释:

Logo的海龟

向后 X , 后 X

海龟向后移动x个点的距离

例如::

向后 50

课程里的解释:

Logo的海龟

向左 X , 左 X

海龟向左转x度角

例如::

向左 90

课程里的解释:

Logo的海龟

向右 X , 右 X

海龟向右左转x度角

例如::

向右 90

课程里的解释:

Logo的海龟

复位

海龟回到中心原点

例如::

复位

课程里的解释:

Turtle world

setx NUM_x

海龟移动到指定的 X 轴的位置

例如::

setx 100

课程里的解释:

Turtle world

sety NUM_y

海龟移动到指定的 Y 轴的位置

例如::

sety 200

课程里的解释:

Turtle world

setxy NUM_X NUM_Y , set pos [ NUM_X NUM_Y ]

海龟移动到指定的位置

例如::

setxy 100 100

课程里的解释:

Turtle world

设置前进方向 , seth

海龟旋转到指定的方向

例如::

sh 145

课程里的解释:

Turtle world

arc ANGLE RADIUS

设定一个弧距,角度数值在前,半径数值在后

例如::

ARC 360 5

课程里的解释:

Turtle world

ellipse WIDTH HEIGHT

创作一个椭圆,并设置椭圆的宽度和高度

例如::

ellipse 80 90

海龟动态查询

pos

将海龟当前所在(x轴和y轴)的位置输出

例如::

pos

课程里的解释:

The turtle answer

xcor

将海龟当前所在(x轴和y轴)的位置输出

例如::

xcor

课程里的解释:

The turtle answer

ycor

将海龟当前所在(x轴和y轴)的位置输出

例如::

ycor

课程里的解释:

The turtle answer

heading

将海龟当前转向的位置输出

例如::

heading

课程里的解释:

The turtle answer

towards

输出朝向指定 [ x y ] 坐标的方位

例如::

towards

课程里的解释:

The turtle answer

Turtle and Window Control

showturtle , st

显示海龟

例如::

ht 等 st

hideturtle , ht

隐藏海龟

例如::

hideturtle

clean , cs

Will clear the screen

例如::

前 60 clean

课程里的解释:

Logo的海龟

clearscreen , cs

清除屏幕并让海龟回到原点

例如::

cs

课程里的解释:

Logo的海龟

fill

Does a paint bucket flood fill at the turtle's position

例如::

cs 重复 4 [ 前 50 右 90 ] 提笔 setxy 50 50 放笔 fill

课程里的解释:

Background

filled fillcolor [ statements ... ]

Execute statements without drawing but keeping track of turtle movements. When complete, fill the region traced by the turtle with fillcolor and outline the region with the current pen style

例如::

filled "blue [repeat 4 [fd 100 右 90]]

课程里的解释:

Background

label expr

Draw a word (same logic as print) on the graphics display at the turtle location

例如::

label "logo ht

课程里的解释:

Background

setlabelheight expr

Set the height for text drawn by label, in pixels

例如::

setlabelheight 100 label "Logo ht

课程里的解释:

Background

envolver

If the turtle moves off the edge of the screen it will continue on the other side

例如::

cs envolver 前 800

课程里的解释:

The turtle borders

ventana

The turtle can move past the edges of the screen, unbounded.

例如::

cs ventana 前 600 右 90 前 100 右 90 前 70

课程里的解释:

The turtle borders

fence

If the turtle attempts to move past the edge of the screen it will stop.

例如::

cs fence 前 600 右 90 前 100 右 90 前 70

课程里的解释:

The turtle borders

Turtle and Window Queries

shownp , shown?

Outputs 1 if the turtle is shown, 0 if the turtle is hidden

例如::

show shown?

课程里的解释:

Interactive

labelsize

Outputs the height of text drawn by label, in pixels

例如::

show labelsize

课程里的解释:

Interactive

Pen and Background Control

提笔 , 提笔

Turtle stops leaving a trail

例如::

提笔

放笔 , 放笔

The turtle will leave a trail

例如::

放笔

设置颜色 X , 设置画笔的颜色 X
Will set the turtle color accroding to the following table
0: 黑色 1: 蓝色 2: 绿黄色
3: 青色 4: 结束 5: 紫红色
6: 您好 7: 白色 8: 棕色
9: tan 10: 绿色 11: 碧绿色
12: 浅橙色 13: 紫色 14: 橙色
15: 灰色

例如::

设置颜色 1

课程里的解释:

Colors and printing

设置颜色 [r,g,b] , 设置画笔的颜色 [r,g,b]

Will set the turtle color accroding to the amount of red , green and blue

例如::

设置颜色 [50 100 50]

设置宽度 X , 设置画笔的尺寸 X

Will set the pen width to X

例如::

设置宽度 4 前 50

课程里的解释:

The pen width

changeshape X or STR , csh X or STR

Will change the turtle to another shape accordin to the following 0 = "turtle", 1 = "cat", 2 = "fish", 3 = "dog", 4 = "horse", 5 = "tiger", 6 = "crab", 7 = "snail"

例如::

csh 1 or csh "dog

课程里的解释:

Turtle world

Pen Queries

pendownp , pendown?

Outputs 1 if the pen is down, 0 otherwise

例如::

show pendown?

课程里的解释:

Interactive

pencolor , pc

Outputs the current pen color. This will be a CSS color string, not necessarily the value passed in.

例如::

show pencolor

课程里的解释:

Interactive

pensize

Outputs a two element list with the pen width and height (usually the same).

例如::

show pensize

课程里的解释:

Interactive

Procedure Definition

到 PROCNAME inputs ... statements ... end

Define a new named procedure with optional inputs

例如::

到 TURTLE 重复 4 [ 前 50 右 90] 结束

课程里的解释:

The turtle is learning

define PROCNAME inputs ... statements ... end

Define a new named procedure with optional inputs

例如::

define "star [[n][repeat 5 [fd :n 右 144]]]

def PROCNAME

Outputs the definition of a named procedure as a string

例如::

show def "star

Variable Definition

定义 varname expr

Update a variable or define a new global variable. The variable name must be quoted

例如::

定义 "foo 5

课程里的解释:

Variables

name expr varname

Like make but with the inputs reversed

例如::

name 5 "myvar

课程里的解释:

No lesson yet

localmake varname expr

Define a variable in the local scope (shortcut for local then make

例如::

localmake "myvar 5

课程里的解释:

No lesson yet

: VARNAME , thing VARNAME

Outputs the value of variable. :foo is a shortcut for thing "foo

例如::

show thing "myvar

课程里的解释:

Variables

Control Structures

重复 X [ statements ... ]

Repeat statements X times

例如::

重复 4 [ 前 50 右 90]

课程里的解释:

Loops

循环 controllist [ statements ...]

Typical for loop. The controllist specifies three or four members: the local varname, start value, limit value, and optional step size

例如::

循环 [i 1 10 1] [print :i]

课程里的解释:

The for loop

重复次数

Outputs the current iteration number of the current repeat or forever

例如::

重复 4 [ 重复次数 ]

if expr [statement]

Execute statment if expressoin is true

例如::

if 2>1 [print "hello]

ifelse expr [statementTrue] [statementFalse]

Execute StatementTrue if tru else execute statementFalse

例如::

ifelse 0>1 [print "true] [print "false]

test expr

Test the specified expression save the result in the local scope for the subsequent use by iftrue iffalse

例如::

test 3>4 iftrue [print "true] iffalse [print "false]

iftrue [statements]

例如::

test 3>4 iftrue [print "true] iffalse [print "false]

iffalse [statements]]

例如::

test 3>4 iftrue [print "true] iffalse [print "false]

等 X

Will cause the turtle to wait X ( 60ths of seconds ) time before executing the command

例如::

重复 4 [ 等 10 前 50]

课程里的解释:

Hi wait

再见

Ternimante the program

例如::

再见

dotimes [varname times] [ statements ...]

Run the statements the specified number of times. The variable varname is set to the current iteration number.

例如::

dotimes [ i 5 ] [ show :i * :i ]

do.while [ statements ...] expr

Runs the specified statements at least once, and repeats while the expression is non-zero (true).

例如::

do.while [ 定义 "a 随机 10 show :a ] :a < 8

while [expr] [ statements ...]

Runs the specified statements only while the expression remains non-zero (true).

例如::

while (random 2) = 0 [ show "zero ] show "one

do.until [ statements ...] [expr]

Runs the specified statements at least once, and repeats while the expression is zero (false).

例如::

do.until [ 定义 "a 随机 10 show :a ] :a < 8

until [expr] [ statements ...]

Runs the specified statements only while the expression remains zero (false).

例如::

until (random 2) = 0 [ show "one ] show "zero

Lists

列表 thing1 thing2 ...

Create a new list from the inputs

例如::

定义 "mylist (list "turtle "academy)

课程里的解释:

Lists

第一个 listname

Outputs the first item from the list

例如::

打印 第一个 :mylist

课程里的解释:

Lists

butfirst listname

Outputs all the items of listname except for the first item

例如::

打印 butfirst :mylist

课程里的解释:

Accessing the list

最后一个 listname

Outputs the last item from the list

例如::

打印 最后一个 :mylist

课程里的解释:

Lists

butlast listname

Outputs all the items of listname except for the last item

例如::

打印 butlast :mylist

课程里的解释:

Accessing the list

item index listname

Outputs the indexlist item of the list or array

例如::

打印 item 1 :mylist

课程里的解释:

Accessing the list

pick index listname

Outputs one item from a list, at random

例如::

打印 pick :mylist

课程里的解释:

Accessing the list

Math

合计 X Y

Will sum x+y

例如::

打印 合计 2 3

课程里的解释:

Variables

减 X Y

return the distance between x and y x-y

例如::

打印 减 8 2

随机 X

Will choose a random number between 0 - (X-1)'

例如::

cs 打印 合计 随机 10 3

课程里的解释:

Colors and printing

modulo expr expr

Outputs the remainder (modulus). For remainder and % the result has the same sign as the first input; for modulo the result has the same sign as a the second input.

例如::

cs 打印 modulo 10 3

power expr expr

3 power 4 = 81

例如::

show power 3 4

Receivers

leerpalabra

Prompt the user for a line of input. The result (including spaces) is the single word output.

例如::

定义 "name (readword [What is your name?]) show :name

课程里的解释:

Interactive

leerlista

Prompt the user for a line of input. The result is a list of words.

例如::

定义 "colors (readlist [Type some colors:]) show :colors

Predicates

word thing , word? thing

Returns true (1) or false (0) if thing is a word

例如::

show word "hello

listp thing , list? thing

Returns true (1) or false (0) if thing is a list

例如::

打印 listp [1 2 3]

arrayp thing , array? thing

Returns true (1) or false (0) if thing is an array

例如::

打印 arrayp array 2

numberp thing , number? thing

Returns true (1) or false (0) if thing is a number

例如::

打印 numberp 25

emptyp thing , empty? thing

Test if thing is an empty list or empty string.

例如::

打印 emptyp []

equalp expr expr , equal? expr expr

Test if xper expr are equal.

例如::

equalp "no "yes

notequalp expr expr , notequal? expr expr

Test if xper expr are not equal.

例如::

notequalp "no "yes

beforep thing1 , before? thing1

Test string collation order.

例如::

打印 before? "bye "hi

substringp thing1 thing2 , substring? thing1 thing2

Test if thing1 is a substring of thing2.

例如::

打印 substringp "hello "helloworld