You are on page 1of 17

Logo Dance

Control
&
Elementary
Programming
Course

C. Rutter 1 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
February 03

C. Rutter 2 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
Houses
Can you draw this
picture?

Here are some


commands that might help you:

601

back forward
right left
bk fd rt lt
penup pendown showturtle hideturtle
pu pd st ht

penerase penpaint setpencolour setpensize [5 5 ]


pe ppt setpc
clearscreen home setheading 0
cs seth 0

Can you add some chimneys and trees in the garden?


Can you add a path?
Can you add a garden?
Can you draw a row of houses?
Here are some colours
0 Black 8 Brown
1 Blue 9 Ochre
2 Green 10 Dark Green
3 Cyan 11 Turquoise
4 Red 12 Orange
5 Magenta 13 Violet
6 Yellow 14 Gold
7 White 15 Grey

You can use them in the command setpc n.


Some of the spellings and most unusual. Learn the ones you don’t know.

C. Rutter 3 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
Yellow

C. Rutter 4 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
Shapes repeat

602

You can use the repeat command to draw shapes.

repeat 2 [ fd 30 rt 90 fd 50 rt 90 ]

What shape does this draw?


Can you use the repeat command to draw other non regular shapes?
Draw three more shapes.

Try this:

rt 30 fd 50
Copy it onto paper, write down what it does.
Do NOT clear the screen.
repeat 2 [rt 30 fd 50 ]
Copy it onto paper, write down what it does.
repeat 3 [rt 30 fd 50 ]
Copy it onto paper, write down what it does.
repeat 4 [rt 30 fd 50 ]
Copy it onto paper, write down what it does.
What will you need to type to finish the shape?

Could you draw the whole shape using just one line of instructions?
How?

Yellow

C. Rutter 5 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
Programming. To and EDALL

The turtle already knows many tricks,


like:

fd bk lt rt cs setpc
and to repeat many tricks:
repeat 4 [fd 50 rt 90]

We can teach the turtle new tricks,which it then remembers. the turtle is intelligent,
once it has learned ‘square’ or ‘triangle’, we can just say:
square fd 50 triangle
There are two ways we can teach the turtle a square.Try this.:
edall
In the new window type this:

When it is ready- click on File/ Save &Exit


Now type
cs
square
fd 10
square
Type Edall. Now go back to the line repeat 4, and change fd 50 to
fd 60.
We see nothing till we have exited the Editor, and typed square.
Teach the turtle to draw Triangles, Stars, Pentagons, Hexagons..
Once you have taught the turtle a new trick, it remembers it till you close the LOGO
program.

C. Rutter 6 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
603

C. Rutter 7 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
604 Programming: Putting it together

Write a ‘trick’ to draw a square and a triangle. Make sure that the side
length is the same in both shapes.
You call the editor with edall

You can now call up these tricks (real name procedures ) with other LOGO
commands (real name primitives) inside another procedure.

Suppose you want your turtle to draw this.

You may already see what is wrong with this program, if not type it in and try
running it-it needs a couple of extra commands.
Try writing programs to draw a space rocket or a tower block.

Below is a picture of a sailing ship. I used a trick called mast which was made up of
square. Have a go.

red

C. Rutter 8 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
C. Rutter 9 Wilmington Hall School
Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
Programming Teach the turtle this trick

to square
repeat 4 [ fd 50 lt 90 ]
end

Yes it will draw a square! But we now teach the turtle ..


to spinning.square
repeat 6 [ lt 60 square ]
end
Each one of these tricks is called a procedure. A procedure may call other
procedures. The final show is called a program. Programs are made up of
procedures and ‘glue’ instructions to join the procedures sensibly. Write your own
progam to spin a shape of your choice?

C. Rutter 10 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
605

C. Rutter 11 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
606 WOW

Two ways to do eyes

C. Rutter 12 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
WINDMILL 607
Look at the windmill program in the public area.
Type Windmill to make it turn.

How does it do it?


Simple.

We set the turtle to PPT


Draw the sweeps.
Now set the turtle to PE
Draw the sweeps again- this time they will be erased.
move the turtle right 20 and start again.

This will happen so fast that you will want to put in some wait
statements.

You can do this yourself. You need two procedures- one to draw the shape- one to make it move.
Go into edall and type in this.

TO SPIN

PPT
REPEAT 2000 [

THISSHAPE ;DRAW IT
WAIT 20
PE
THISSHAPE ;ERASE IT
WAIT 10
RT 20 ;TWIST A LITTLE
]
END

TO THISSHAPE
; YOU CAN PUT ANY SHAPE IN HERE
REPEAT 4 [ FD 50 RT 90 ]
END

Now that this works, there are many things you can do.
1. You can change the pen colour before you start . SETPC 4.
2. You can change the pensize before you start SETPENSIZE [5 5]

C. Rutter 13 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
3. Change the shape of THISSHAPE so it looks like a windmills sails. You must make sure that the
turtle ends up exactly where it started- facing in exactly the same direction.
4. You can make it go faster or slower.

What happens if you change the RT 20 in SPIN to read FD 20. You could draw a little car (or
elephant) and get it drive across the screen. How? Try it!
pink

C. Rutter 14 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
608 Programming: Very variable
Type in this procedure. You must type it exactly and when you are finished click
File/Save&Exit

to square :sidelength
repeat 4 [ lt 90 fd :sidelength ]
end
File/Save&Exit
square 20
What happens?
Now type
square 70
Investigate for other numbers.

The :sidelength is called a variable. You can use any number of them. The name
must start with a :. It is called a colon, or double dot. To the turtle it means ‘the
contents of the variable.You must list all the ones you will use on the first line of the
definition.
New Definition. These variables act as arguments or parameters.
We call the :sidelength in the definition, a parameter- and the number that goes into
it when it is called, the argument.
Now type
to spinner
repeat 6 [lt 30 square 70 lt 30 square 40 ]
end
Can you think of a way to write a procedure that allows you to vary the size of
square, in spinner?.

C. Rutter 15 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
Purple

C. Rutter 16 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc
Traffic lights 609
Go to the Public area and double click on Traffic.
This opens the logo program with some pre written code

These are the commands that have been written for you.

build
lamp
wait

build
To draw the traffic light you type
To switch on the lamp- you type lamp “red “on
To switch off the lamp you type lamp “red “off

There are three lamps, red orange green. You must not
miss out the quote mark or put in a space.

Your task is to go to edall and write a procedure called cycle.

Keep on trying till you get it right.

Purple

C. Rutter 17 Wilmington Hall School


Printed 12-Jan-03 /conversion/tmp/activity_task_scratch/603910779.doc

You might also like