Lugar ng Paglalaro

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

Upang i-save ang iyong programa, mangyaring mag-login o magrehistro

Turtle Motion

pasulong X , pa X

Inililipat ang pagong ng x puntos

Halimbawa:

pasulong 50

Ipinaliwanag sa aralin:

Ang turtle ng Logo

paatras X , paat X

Ang pagong ay babalik ng x punto

Halimbawa:

paatras 50

Ipinaliwanag sa aralin:

Ang turtle ng Logo

kaliwa X , kal X

I-ikot ang pagong pakaliwa ng x degrees

Halimbawa:

kaliwa 90

Ipinaliwanag sa aralin:

Ang turtle ng Logo

kanan X , kan X

Iikot ang turtle sa kanan ng x na mga degree

Halimbawa:

kanan 90

Ipinaliwanag sa aralin:

Ang turtle ng Logo

bahay

Inililipat ang pagong sa gitna, nakaturo pataas

Halimbawa:

bahay

Ipinaliwanag sa aralin:

Turtle world

ponerx NUM_x

Ilipat ang turtle sa tinukoy na lokasyon ng X

Halimbawa:

ponerx 100

Ipinaliwanag sa aralin:

Turtle world

ponery NUM_y

Ilipat ang turtle sa tinukoy na lokasyon ng Y

Halimbawa:

ponery 200

Ipinaliwanag sa aralin:

Turtle world

ponerxy NUM_X NUM_Y , set pos [ NUM_X NUM_Y ]

Ilipat ang pagong sa tinukoy na lokasyon

Halimbawa:

ponerxy 100 100

Ipinaliwanag sa aralin:

Turtle world

iponerdireksyon , ponerd

I-rotate ang pagong sa tinukoy na pamamaraan

Halimbawa:

sh 145

Ipinaliwanag sa aralin:

Turtle world

arko ANGLE RADIUS

Maglilikha ng isang arc na may layong RADIUS na sumasakop sa ANGLE na anggulo

Halimbawa:

ARC 360 5

Ipinaliwanag sa aralin:

Turtle world

ellipse WIDTH HEIGHT

Will create an ellipse with Width and height

Halimbawa:

ellipse 80 90

Turtle Motion Queries

pos

Naglalabas ng kasalukuyang posisyon ng turtle bilang [x y], x o y ayon sa pagkakasunod-sunod

Halimbawa:

pos

Ipinaliwanag sa aralin:

The turtle answer

coorx

Naglalabas ng kasalukuyang posisyon ng turtle bilang [x y], x o y ayon sa pagkakasunod-sunod

Halimbawa:

coorx

Ipinaliwanag sa aralin:

The turtle answer

coory

Naglalabas ng kasalukuyang posisyon ng turtle bilang [x y], x o y ayon sa pagkakasunod-sunod

Halimbawa:

coory

Ipinaliwanag sa aralin:

The turtle answer

direksyon

Outputs the current turtle heading

Halimbawa:

direksyon

Ipinaliwanag sa aralin:

The turtle answer

patungo

Outputs the heading towards the specified [ x y ] coordinates

Halimbawa:

patungo

Ipinaliwanag sa aralin:

The turtle answer

Turtle and Window Control

ipakitatartuga , mt

Ipakita ang pagong

Halimbawa:

ot hintayin mt

Ipinaliwanag sa aralin:

Controlling the Turtle and Pen

itinagongtartuga , ot

Itago ang pagong

Halimbawa:

itinagongtartuga

Ipinaliwanag sa aralin:

Controlling the Turtle and Pen

linisin , bp

Will clear the screen

Halimbawa:

pa 60 linisin

Ipinaliwanag sa aralin:

Ang turtle ng Logo

linisangscreen , bp

Lilinisin ang screen at ibabalik ang turtle sa home

Halimbawa:

bp

Ipinaliwanag sa aralin:

Ang turtle ng Logo

punuin

Maglalagay ng pintura sa loob ng isang lalagyan upang punuin ang lugar na kinaroroonan ng turtle

Halimbawa:

bp ulitin 4 [ pa 50 kan 90 ] sl ponerxy 50 50 bl punuin

Ipinaliwanag sa aralin:

Background

punumpuno 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

Halimbawa:

punumpuno "blue [repeat 4 [fd 100 kan 90]]

Ipinaliwanag sa aralin:

Background

tatak expr

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

Halimbawa:

tatak "logo ot

Ipinaliwanag sa aralin:

Background

poneralturatatak expr

Set the height for text drawn by label, in pixels

Halimbawa:

poneralturatatak 100 tatak "Logo ot

Ipinaliwanag sa aralin:

Background

envolver

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

Halimbawa:

bp envolver pa 800

Ipinaliwanag sa aralin:

The turtle borders

ventana

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

Halimbawa:

bp ventana pa 600 kan 90 pa 100 kan 90 pa 70

Ipinaliwanag sa aralin:

The turtle borders

valla

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

Halimbawa:

bp valla pa 600 kan 90 pa 100 kan 90 pa 70

Ipinaliwanag sa aralin:

The turtle borders

Turtle and Window Queries

shownp , shown?

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

Halimbawa:

show shown?

Ipinaliwanag sa aralin:

Interactive

labelsize

Outputs the height of text drawn by label, in pixels

Halimbawa:

show labelsize

Ipinaliwanag sa aralin:

Interactive

Pen and Background Control

itaasangtinta , sl

Humihinto ang pagong sa pag-iiwan ng marka

Halimbawa:

itaasangtinta

Ipinaliwanag sa aralin:

Controlling the Turtle and Pen

ibabaangtinta , bl

Mag-iiwan ng marka ang pagong

Halimbawa:

ibabaangtinta

Ipinaliwanag sa aralin:

Controlling the Turtle and Pen

maglagayngkulay X , maglagayngkulayngtinta X
Itatag ang kulay ng pagong ayon sa sumusunod na talahanayan
0: itim 1: asul 2: luntian
3: tsyan 4: pula 5: magenta
6: dilaw 7: puti 8: kayumanggi
9: tan 10: berde 11: akuamarin
12: salmon 13: lila 14: kamatis
15: kulay-abo

Halimbawa:

maglagayngkulay 1

Ipinaliwanag sa aralin:

Colors and printing

maglagayngkulay [r,g,b] , maglagayngkulayngtinta [r,g,b]

Magtatakda ng kulay ng turtle ayon sa halaga ng pula, berde, at asul

Halimbawa:

maglagayngkulay [50 100 50]

maglagaynglapad X , maglagaynglapadngtinta X

Itatag ang lapad ng lapis sa X

Halimbawa:

maglagaynglapad 4 pa 50

Ipinaliwanag sa aralin:

The pen width

baguhinangporma X or STR , bagu X or STR

Magpapalit ng anyo ng turtle ayon sa sumusunod na mga halaga: 0 = "turtle"(tartaruga), 1 = "cat" (pusa), 2 = "fish" (isda), 3 = "dog" (aso), 4 = "horse" (kabayo), 5 = "tiger" (tigre), 6 = "crab" (alimango), 7 = "snail" (suso)

Halimbawa:

bagu 1 or bagu "dog

Ipinaliwanag sa aralin:

Turtle world

Pen Queries

pendownp , pendown?

Outputs 1 if the pen is down, 0 otherwise

Halimbawa:

show pendown?

Ipinaliwanag sa aralin:

Interactive

pencolor , pc

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

Halimbawa:

show pencolor

Ipinaliwanag sa aralin:

Interactive

pensize

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

Halimbawa:

show pensize

Ipinaliwanag sa aralin:

Interactive

Procedure Definition

sa PROCNAME inputs ... statements ... end

Tukuyin ang isang bagong pangalan ng pamamaraan na may mga opsyonal na input

Halimbawa:

sa TURTLE ulitin 4 [ pa 50 kan 90] wakas

Ipinaliwanag sa aralin:

The turtle is learning

define PROCNAME inputs ... statements ... end

Define a new named procedure with optional inputs

Halimbawa:

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

def PROCNAME

Outputs the definition of a named procedure as a string

Halimbawa:

show def "star

Variable Definition

gumawa varname expr

I-update ang isang variable o magtakda ng isang bagong global na variable. Ang pangalan ng variable ay dapat naka-quote

Halimbawa:

gumawa "foo 5

Ipinaliwanag sa aralin:

Variables

name expr varname

Like make but with the inputs reversed

Halimbawa:

name 5 "myvar

Ipinaliwanag sa aralin:

No lesson yet

localmake varname expr

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

Halimbawa:

localmake "myvar 5

Ipinaliwanag sa aralin:

No lesson yet

: VARNAME , thing VARNAME

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

Halimbawa:

show thing "myvar

Ipinaliwanag sa aralin:

Variables

Control Structures

ulitin X [ statements ... ]

Ulitin ang mga pahayag nang X beses

Halimbawa:

ulitin 4 [ pa 50 kan 90]

Ipinaliwanag sa aralin:

Loops

para controllist [ statements ...]

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

Halimbawa:

para [i 1 10 1] [print :i]

Ipinaliwanag sa aralin:

The for loop

bilanginangulit

Outputs the current iteration number of the current repeat or forever

Halimbawa:

ulitin 4 [ bilanginangulit ]

kung expr [statement]

Execute statment if expressoin is true

Halimbawa:

kung 2>1 [print "hello]

kunghindi expr [statementTrue] [statementFalse]

Execute StatementTrue if tru else execute statementFalse

Halimbawa:

kunghindi 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

Halimbawa:

test 3>4 kungtotoo [print "true] kunghindi [print "false]

kungtotoo [statements]

Halimbawa:

test 3>4 kungtotoo [print "true] kunghindi [print "false]

kunghindi [statements]]

Halimbawa:

test 3>4 kungtotoo [print "true] kunghindi [print "false]

hintayin X

Magpapahintulot sa turtle na maghintay ng X (60th ng segundo) bago ipatupad ang utos

Halimbawa:

ulitin 4 [ hintayin 10 pa 50]

Ipinaliwanag sa aralin:

Hi wait

paalam

Ternimante the program

Halimbawa:

paalam

dotimes [varname times] [ statements ...]

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

Halimbawa:

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).

Halimbawa:

do.while [ gumawa "a random 10 show :a ] :a < 8

while [expr] [ statements ...]

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

Halimbawa:

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).

Halimbawa:

do.until [ gumawa "a random 10 show :a ] :a < 8

until [expr] [ statements ...]

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

Halimbawa:

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

Mga Listahan

talaan thing1 thing2 ...

Lumikha ng isang bagong listahan mula sa mga input

Halimbawa:

gumawa "mylist (list "turtle "academy)

Ipinaliwanag sa aralin:

Mga Listahan

unang listname

Naglalabas ng unang item mula sa listahan

Halimbawa:

iprint unang :mylist

Ipinaliwanag sa aralin:

Mga Listahan

perohuli listname

I-output ang lahat ng mga item ng listname maliban sa unang item

Halimbawa:

iprint perohuli :mylist

Ipinaliwanag sa aralin:

Accessing the list

huling listname

Naglalabas ng huling item mula sa listahan

Halimbawa:

iprint huling :mylist

Ipinaliwanag sa aralin:

Mga Listahan

perohuli listname

I-output ang lahat ng mga item ng listname maliban sa huling item

Halimbawa:

iprint perohuli :mylist

Ipinaliwanag sa aralin:

Accessing the list

item index listname

Outputs the indexlist item of the list or array

Halimbawa:

iprint item 1 :mylist

Ipinaliwanag sa aralin:

Accessing the list

pumili index listname

I-output ang isang item mula sa isang listahan, sa random

Halimbawa:

iprint pumili :mylist

Ipinaliwanag sa aralin:

Accessing the list

Math

sum X Y

Will sum x+y

Halimbawa:

iprint sum 2 3

Ipinaliwanag sa aralin:

Variables

minus X Y

Ibalik ang distansya sa pagitan ng x at y x-y

Halimbawa:

iprint minus 8 2

random X

Pipili ng isang random na numero sa pagitan ng 0 - (X-1)

Halimbawa:

bp iprint sum random 10 3

Ipinaliwanag sa aralin:

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.

Halimbawa:

bp iprint modulo 10 3

power expr expr

3 power 4 = 81

Halimbawa:

show power 3 4

Receivers

basahinangsalita

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

Halimbawa:

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

Ipinaliwanag sa aralin:

Interactive

basahinangtalaan

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

Halimbawa:

gumawa "colors (readlist [Type some colors:]) show :colors

Predicates

word thing , word? thing

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

Halimbawa:

show word "hello

listp thing , list? thing

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

Halimbawa:

iprint listp [1 2 3]

arrayp thing , array? thing

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

Halimbawa:

iprint arrayp array 2

numberp thing , number? thing

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

Halimbawa:

iprint numberp 25

emptyp thing , empty? thing

Test if thing is an empty list or empty string.

Halimbawa:

iprint emptyp []

equalp expr expr , equal? expr expr

Test if xper expr are equal.

Halimbawa:

equalp "no "yes

notequalp expr expr , notequal? expr expr

Test if xper expr are not equal.

Halimbawa:

notequalp "no "yes

beforep thing1 , before? thing1

Test string collation order.

Halimbawa:

iprint before? "bye "hi

substringp thing1 thing2 , substring? thing1 thing2

Test if thing1 is a substring of thing2.

Halimbawa:

iprint substringp "hello "helloworld