Logowkshts
Logowkshts
Introduction
What is LOGO?
Logo is a programming language. This means that you can give the computer a list of
instructions that the computer will then carry out. However, it is important that you use
the correct vocabulary, just like any other language, for example French or English.
Turtle Graphics.
What makes Logo different from other computer languages is its ability to handle
drawing commands. To do this it uses something called “Turtle Graphics”. The ‘Turtle’
can be moved around the screen, leaving a trail behind it.
Getting Started
You need to understand that if you give the turtle an instruction, then it will carry it out
straight away, as long as you have used the correct command correctly.
Find the LOGO icon on the desktop, double click it to start the program.
A pop-up window will appear, if you read the information in this box, you will see that
MSWLogo is freeware. This means that the program is free to anybody who wants it. If
you would like a copy for your computer at home, either:
WINDOWS 95/98/ME/NT/2000
1. Fetch a HD disk from home and ask Mr. Presley to copy the program for you.
or
LOGO SCREEN
This is where your work will appear.
THE TURTLE
COMMANDER SCREEN
This is where you do your work.
The Commander is a window that sits on top of the Logo Screen, it can be moved and
resized just like any other window. If you want to do something straight away, type this
into the long white box at the bottom of the Commander window.
FORWARD 100
Then either press the return key or click on the execute button.
What happened?
You can send the turtle back to where it started from by typing HOME. This moves the
turtle in a straight line to its starting position in the middle of the screen. It will leave any
lines that you have drawn. However, it will also draw a new line from its old position
back to its home position.
You can make the turtle go back to where it started from and clear the screen by clicking
the RESET button.
Left and Right will make the turtle turn by a given angle, they will not make the turtle move
to the left, or to the right.
Type CS to clean the screen and send the turtle back to its starting position.
Now try and draw these shapes (ask your teacher to check each one as you do it).
MSWLogo page 3
BACK (or BK). This moves the turtle back an amount, it must be followed by a
number.
Moving without drawing
PENUP (or PU). This stops the turtle from drawing so that you can move to
another part of the screen without leaving a line.
PENDOWN (or PD). Makes the turtle start drawing again.
PENERASE (or PE). Allows you to rub out any lines that you have drawn by
mistake. Simply make the turtle move over the line that you
want to rub out.
Try this:
FD 100 RT 90 FD 100
PE
BK 100 LT 90 BK 100
PPT
The turtle must move over the line to rub it out.
PENPAINT (or PPT). Makes the turtle draw again after using PE.
SETPENCOLOR Changes the colour, note the spelling (this is an American
program). You must use it like this:
SETPENCOLOR [COL1 COL2 COL3]
COL1, COL2 and COL3 are numbers between 0 and 255.
CLEAN Rubs out everything on the screen. This does not move the
turtle.
FD 100 LT 90
FD 100 LT 90
FD 100 LT 90
FD 100 LT 90
Really you have told the turtle to do this, FD 100 LT 90, four times.
REPEAT 4 [ FD 100 LT 90 ]
Investigate:
What other shapes and patterns can you make using the REPEAT command?
When you have finished writing your procedure you can test it or save it.
To save your procedure, do FILE - EXIT. If you have made a mistake, for example missed a bracket out,
then the computer will tell you there is something wrong and give you the chance to try again.
To make your procedure work, just type its name in the Commander window.
Write procedures to draw 4 squares. The squares should be these sizes 25, 50, 75 and 100.
To SQUARE25 To SQUARE50
Repeat 4 [ fd 25 rt 90] repeat 4 [ fd 50 rt 90]
end end
and so on.
However, it is possible to write a procedure that allows you to draw any size square.
TO SQUARE :length
REPEAT 4 [ FD :length RT 90 ]
END
Reset the screen and then run the procedure like this:
SQUARE 25
SQUARE 50
and so on.
Note, all we did was replace the number of steps to move e.g. FD 25, with a variable called
:length
(the : is important, it tell the computer it is using a variable). Now when we call square we must
tell the computer how big the square should be. However we can still do better. What’s wrong
now, you ask. Well wouldn’t it be better if we could draw something other than a square, a
triangle?
1. See what the following commands do, write procedures to show how they can be used.
SETPOS
LABEL
SHOW POS
SETH
SETPC [needs 3 numbers]
SETSC [needs 3 numbers]
SOUND [needs 2 numbers]
2. Write a procedure called HOUSE that draws a house, complete with 4 windows, door,
roof and chimney. Produce a report to show how you completed this task.
3. Write a new procedure called STREET that draws a row of houses. You must tell the
computer how many houses to put in the street. Produce a report to show how you
completed this task.
4. Write a procedure to draw a train. If you finish this with ease, then animate the train
(make it move). Produce a report to show how you completed this task.
5. Draw a dart board using Logo, don’t worry too much about which number goes
where. Produce a report to show how you completed this task.
6. Draw a spiral, it starts in the centre of the screen and works its way out. Produce a
report to show how you completed this task.
7. Write a procedure called TOWER that draws a skyscraper, this should use a variable to
control the height of the tower. Produce a report to show how you completed this task.