Data Loading...
logo command book Flipbook PDF
logo command book
182 Views
330 Downloads
FLIP PDF 147.21KB
MSW Logo – Workbook 1
A FEW MORE COMMANDS The boundaries of your screen are controlled by the commands WRAP, FENCE and WINDOW. WRAP If the turtle is asked to move past the boundary of the graphics
MSW Logo Workbook One
window, it will "wrap around" and reappear at the opposite edge of the window
FENCE
if the turtle is asked to move past the boundary of the graphics window, it will move as far as it can and then stop at the edge with an "out of bounds" error message
WINDOW
if the turtle is asked to move past the boundary of the graphics window, it will move off screen. The visible graphics window is considered as just part of an infinite graphics plane; the turtle can be anywhere on the plane.
You can find out the difference between them by typing these codes. CS WRAP FD 900 CS FENCE FD 900 CS WINDOW FD 900
YEAR 7
RANDOM [n] Produces a random number that is less than the number n
Highgate Wood School Now, try and work out what this piece of code will produce CS WRAP REPEAT 2000 [SETPC RANDOM 16 SETPENSIZE [20 20] FD RANDOM 100 RT RANDOM 360]
Think about it first and then see whether it turns out as you expected.
Page 8
MSW Logo – Workbook 1
Basic Logo Commands (n = the number you type in)
FD n
Cursor moves forward n units
BK n
Cursor moves backward n units
RT n
Cursor turns right by n degrees
LT n
Cursor turns left by n degrees
CS
Clears screen
There must be a space between the command and the number
Using the Basic Logo Commands draw out the shapes you expect to get with these instructions: 1)
CS FD 10 RT 90 FD 10 RT 90 FD 10 RT 90 FD 10 2)
CS FD 10 RT 120 FD 10 RT 120 FD 10
3)
CS FD 10 LT 60 FD 10 RT 60 FD 10
4)
CS FD 10 LT 90 BK 10 RT 60 FD 10 5)
CS FD10 LT30 Page 2
MSW Logo – Workbook 1
TASK
LEARNING
Look back on the commands that you already know and use them to control the movement of the turtle on screen to create a range of interesting shapes. You can put your name on them by using the command: LABEL [Your name] Try and keep a record of screenshots of the programming that you have done. Extra credit will be given for those who show evidence of them finding errors in their programming which they then correct. Most of the time errors occur because you forget to leave a space between the command and the argument. But things also go wrong when you don’t spell a command correctly. If it is not exactly a command that MSWLogo recognises it will not be able to do anything and just return an error message
What are you doing this for? Putting instructions in sequence is one of the most important aspects of ICT. Working through lines of code in a logical and thoughtful way – working out what they mean and why they might not be giving the results that you had expected is a vital skill..
When you are working with MSW Logo try not to just type in the examples you are given. Try and think about what you want the turtle to do on screen first and then think of the instructions you should give. It is fine to make mistakes. It is probably the best way to learn programming!
Page 7
MSW Logo – Workbook 1
Now that you know the repeat function you can create some procedures much more quickly and efficiently. For example, to draw a square: REPEAT 4 [FD 40 RT90] To draw a triangle: REPEAT 3 [FD 50 RT 120] To draw an octagon: REPEAT 8 [FD 50 RT 45]
MSW Logo – Workbook 1
You are now ready to make many more interesting shapes. You can use the REPEAT command more than once. What do you think you would get with the following set of instructions:
This is the main MSW Logo screen where the results of your instructions to the turtle are shown
Main Logo Screen
REPEAT 100 [REPEAT 3 [FD 50 RT 120] RT 10]
To draw a circle: REPEAT 360 [FD 20 RT 1]
Test it out!
Try and create all these shapes. Change the arguments, so they are larger or smaller. You can change the Commands too. What will happen if you replace FD with BK or RT with LT? You might also want to change things like the Pen Colour. This shape was created using
Experiment with using the REPEAT command until you are confident that you can do it, and correct the errors you might make
There are useful functions on the toolbar – with short cuts to changing the colour, the ability to save the screen image and lots of Help files
REPEAT 40 [REPEAT 360 [FD 1 RT 1] RT 10]
Finding errors and correcting them is more important than anything .
Page 6
Input your instructions in the Input Box of the commander window
Buttons on the Commander Window allow you a variety of options, including the Halt function which stops the procedure that is running
Now that you have launched MSW Logo you should go through the earlier procedures and see if your answers were right. Carry on using the basic commands with MSW Logo until you are confident that you can do it.
Command
What to do
Argument
By how much
The most common error is to forget to put a space between the Command and the Argument.
If you want the turtle to return to its original position simply type in the Command HOME.
Return (Enter ↵) Do it!
Page 3
MSW Logo – Workbook 1
MORE MSW LOGO COMMANDS Command PU
What it does Turtle’s pen is up (so it doesn’t draw as it moves)
PD
Turtle’s pen is down (so it does draw as it moves)
PE
Turtle erases as it moves.
HT
Hide turtle (removes turtle triangle from
MSW Logo – Workbook 1
Practise using these new commands… explore what happens. Don’t worry if you make a mistake, simply type CS to clear the screen and then start again. Program Logo to draw a red box, and then a blue triangle.
screen)
ST
Show turtle (makes turtle triangle visible again)
HOME
Returns Turtle to the “home” position in the centre of the screen (you should issue a PU command to prevent it drawing its return path)
LABEL [word]
Displays the text you have written at the Turtle’s location.
SETPC [n]
Sets the pen colour depending on the number you have written – (between 0 and 15). [4 is red, 2 is green and 1 is blue]
SETPENSIZE [n n]
Sets width and height of the drawing pen. MSW Logo uses only the second value.
SETSC [n n n]
Sets screen colour (the numbers are the intensity of red, blue and green and can be between 0 and 255)
BYE
Exits MSW Logo
Page 4
MAIN TASK When you are confident in using these commands and program logo to write your name or initials. Save it as a screenshot in Word or a bitmap.
SAVING YOUR WORK FROM MSW LOGO There are different ways of saving your work from Logo. If you press the Prt Sc key you will have take a snapshot of your screen and you will be able to paste that into Word and then save it. Alternatively you could save the work on your MSW Logo screen as a picture by clicking on Bitmap in the toolbar and then saving it under an appropriate name in your user area. Finally you can also click on File and save the work as a Logo file (*.lgo) in your user area.
QUESTION What shape would you get with the instructions FD 10, RT 1, FD 10, RT 1 ….. if you were to repeat it 360 times? Wouldn’t it make a lot more sense to be able to program MSW Logo to repeat the instructions 360 times instead of you having to type it out 260 times?
There is that command available – and it is called REPEAT. It makes life a lot simpler for during quite interesting shapes.
Page 5