|
Lesson 2: Turn left turn right |
|
©1997/1998 Sebastian Golze, Thomas Hirsch
und
|
[1_First_steps] [2_Turn_left_turn_rigth] [3_With_colors] [4_Procedures] [5_Parameters] [6_Loops] [7_More_parameters] [8_Stars] [9_Upload_and_Download] [10_LOGO_learns_to_write]
Here is another little program that tells LOGO to draw a square. procedure main Indeed, when you execute this program, LOGO draws a square. You have certainly already seen the command which makes him turn: it's the command right. So why do we have that number beside ? This number tells him how far he's supposed to turn. You, for example, can turn yourself a whole turn, half a turn, and so on. But this number is more precise: It declares an angle measured in degrees. Hey, that doesn't have anything to do with temperatures! ![]() A whole turn consists of 360 degrees. So half a turn is 180, and a quarter turn is 90 degrees. This explains why there's a 90 besides the command right: LOGO turns a quarter turn to the right every time this command is executed . If he repeats this four times and walks a little distance forward after each turn, he draws a square. If you want to, you may try it out yourself - but don't draw on the carpets ! Now turn to the other side: procedure main Look at the two examples again while executing the program step by step. At the end, LOGO does a last turn, so that he looks in the same direction as in the beginning. You should always let him do that in order to know where he looks even if he has repeated a procedure several times. Now try what happens when you enter other numbers after the word right. Use for example the values of 30, 45, 60, 120, 180, 270 or 360. Maybe you'll want to draw some simple figures now. A rectangle, a triangle or a cross should do it for the beginning. First, try to draw the figure with a pencil on paper using only one line. Now you translate every line and every corner into a move or a turn of LOGO. If you don't want to write so much, there are abbreviations for the words right and left: LOGO also understands the words rt and lt |