Nov 242017
Start a new project with the following and save it as “y6logo 2”
- reset
- setpensize 5
Repeat task
- repeat 4 [fd 40 rt 90] draws a square:
- the instructions inside the [] “fd 40 rt 90” are the ones to do again and again
- the “4” means repeat it four times
- Copy the code above to draw a square
- Copy and paste the code again
- Try changing the 4 to a 5. What happens?
- Now change the “rt 90” to “rt 72”
- Copy the code again
- Try changing repeat to 6 – what should the “rt” number be?
- Now try repeat 7: when you draw the shape, the total angle turned is 360 because it comes back to the beginning. It has 7 equal angles so each angle needs to be….360…7
- Copy the code again
- Draw an Octagon (8-sided) and a Nonagon (9-sided)
- Save (if you haven’t already!)
Finished? You should have on your page:
- A square, pentagon, hexagon, heptagon, octagon and nonagon
Setxy
- Setxy is used to move the arrow to a different position on the canvas
- setxy 50 100 sends the arrow to the coordinates (50, 100)
- This Scratch project shows you what the different coordinates are:
- x y coordinate finder (only goes up to 240/180 in Scratch – in LOGO it goes up to 250 on each axis)
- NOTE if the pen is down, it will draw a line to the new position – so it is quite useful to use with pu and pd:
- pu setxy 50 100 pd – will send it to the new place without drawing then is ready to draw
- Use “pu setxy …. pd” to move your shapes from the first section to different places on the canvas.
Procedures
- Procedures are used to avoid typing the same thing several times.
- Use a procedure if you need to repeat something in your picture, eg windows in a house, snowflakes, stars, a fence, stripes, eyes….
- A procedure teaches the computer how to do a shape but doesn’t draw it. Then you “call” the procedure to make it draw it.
- Instead of “repeat 4 [fd 40 rt 90]” at the beginning of your code, have this:
to square
repeat 4 [fd 40 rt 90]
end
- When you play, it will not draw the square – you have only told it how to – not to actually draw it.
- Now type “square” after the procedure and it should draw the square. You have taught it how to draw a square!
- Procedure are usually all at the beginning of the code.
- Make procedures called “pentagon” and “hexagon”
- Instead of drawing one pentagon, use the code: repeat 6 [pentagon rt 60] to make a pentagon flower!
- Make a procedure to fill your shape:
- to fillshape
- pu rt 45 fd 10
- fill
- bk 10 lt 45 pd
- end
- to fillshape
- Call the procedure after each shape you do.
Variables
Lists
Success steps
- Save (as) different versions
- Experiment with new code
- Find your own mistakes by reading your code carefully
- Use repeat, setxy and procedures in your own code