Presentation is loading. Please wait.

Presentation is loading. Please wait.

First of all – lets look at the window’s you are going to use. At the top you have a toolbar, with all your various tools you can use when customising.

Similar presentations


Presentation on theme: "First of all – lets look at the window’s you are going to use. At the top you have a toolbar, with all your various tools you can use when customising."— Presentation transcript:

1 First of all – lets look at the window’s you are going to use. At the top you have a toolbar, with all your various tools you can use when customising your procedures. Under that you have the large window, called ‘Graphics’ where you can see what effect your commands are having. Underneath that you have the ‘Listener’ where you actually give your commands. Talking of commands, lets have a look at a few of the more basic ones, and get your ‘turtle’ doing something.

2 The very first, most used commands you will need are incredibly simple. FD ‘X’ commands your turtle to go forwards by value ‘X’ RT ‘X’ commands your turtle to turn to the right by ‘X’ degrees. Lets do something simple, how about a square. Type fd 50 and then rt 90 four times. Your listener should look like this after you have finished.

3 As you can see, this method, while hard to get wrong, takes quite a lot of typing to get any sort of shape, imagine trying to draw a circle like this. There is a far easier way to do this however. Type CS to clear your screen, so we can start on something slightly more advanced. Now, lets make a circle. Unless you want your hands to fall off though, we are going to have to find a slightly faster way to do this. Lets make a procedure.

4 Now, lets decide what to call your procedure. We’re going to draw a circle, so lets call our procedure ‘circle’. Type edit circle This should open up a new window, like this. It should be titled Circle, and start with TO CIRCLE. Now, lets make it do something shall we. We want it to draw a circle, without having to do lots of typing. The answer to this is the Repeat command.

5 As the name suggests, the repeat command repeats whatever you tell it to. What we are going to do is tell it to draw a circle. So, type: repeat 360 [fd 1 rt 1] This tells the procedure to repeat 360 times the commands fd 1 then rt 1. So the repeat command can be summed up like this: repeat X [Y] Which means repeat command ‘Y’, ‘X’ times. Press F2 to leave the editor. You should see ‘circle defined’ in your listener.

6 Now, lets test our procedure. Type circle into your listener, and press enter. You should see this. To vary the size of your circle, change how much the turtle moved in the FD command in your procedure. However, that takes time, and you aren’t sure of what it will look like until you have done it. Lets speed this up shall we. Lets use variables.

7 A variable is something we can change in the procedure, without having to edit it every time. Lets call our variable ‘X’. So, open your procedure with edit circle, and lets change it around a bit. Where it says, TO CIRCLE, change it so it says TO CIRCLE :X. This means that when you type circle, you must also give a value of X. Now, change your procedure, so is says repeat 360 [fd :X rt 1] Now you can vary how far the turtle moves every repeat. Press F2, and try typing circle 2. You should see this.

8 Now, with variables, a whole new world of possibilities has opened up for us. If we put our minds to it we could make any shape we could ever imagine. You can have as many variables as you like in a procedure, for example you could have a procedure called SHAPE :X :Y :Z Or any other combination. Now lets make a procedure that will make a shape with a number of sides :X and a side length :Y As you may know, the exterior angle of a shape is 360/No. of sides. So our procedure would look something like this. First, lets call it POLYGON. 90 ⁰ 120 ⁰ 30 ⁰ 360 12 360 4 360 3

9 Now, type edit POLYGON into your listener. We need the top to say TO POLYGON :X :Y Then, type repeat :X [fd :Y rt 360/:X] This lets us set the number of sides, and the length of each side. Lets give it a go shall we? Lets start with a square, of side length 50, and of course with 4 sides. You should get this, if not, go back and check for any typo's in your procedure. Now, one more thing before we get onto some really hard stuff.

10 With all the circles we’ve drawn, we have set the circumference, not the radius. Lets see if we can try and make a procedure where we set the radius, of the circle, and the program works out the rest. So first, we’re going to need a variable, :X, and the value of pi. Logo takes this value to 3.14, which is close enough for our means. Lets call our procedure CircleR – meaning it is a circle where you set the radius. So, type ‘edit circler’ in your listener, and type this: Give the procedure a variable :X Tell it to repeat 360 times: forward 2*π*:X then right turn by 1. Remember, to multiply use * not x. R Circumference Circumference = π*R*2 π*D D

11 So, with all that done, does your procedure look like this: TO CIRCLER :X REPEAT 360 [FD ((PI * 2 * :X) / 360) RT 1] END If so – well done, you have made a procedure where the value :X is the radius, and the circumference is done by Logo. Try is out, and you should get this, set :X to 50. This is useful for making a drawing significantly more precise. Now, lets move onto something even better – spirals!


Download ppt "First of all – lets look at the window’s you are going to use. At the top you have a toolbar, with all your various tools you can use when customising."

Similar presentations


Ads by Google