Plan Before You Type
Big programs are not typed from start to finish. They are planned. List the parts of your picture, decide where each one sits, write one block per part, and test each block alone. Then joining them up is the easy bit.
π‘ The idea
Plan a big drawing on paper first, then build it one tested part at a time.
- Sketch the picture on paper and label every part.
- Write down where each part sits, as a goto position, before you code.
- Build one part, run it, fix it. Only then start the next part.
- Comments help: a line starting with # is a note for humans, not the turtle.
- If the finished picture is wrong, you already know which block to look at.
π Words to know
- plan
- decide what to build before you build it
- comment
- a note in the code that the computer ignores
- scene
- a picture made of several parts
π Watch this
Only one part of the scene so far: the sun, tested on its own in the top corner.
# part one of the scene: the sun to sun colour yellow fill on circle 35 end penup goto -140 110 pendown sun
βοΈ Your turn
- Run it. One part working is better than four parts half working.
- Move the sun by changing the goto numbers.
- Add a comment of your own with # at the start of the line.
- Write a second block called cloud and test it by itself.
- Only when both work, call them one after the other.
π― Challenge: Plan a garden: write one block for the ground and one for a flower, test each on its own, then run them together.
Show me one answer
to ground right 90 forward 220 back 440 end to flower repeat 6 [ forward 25 dot 20 back 25 right 60 ] end ground goto 0 0 flower
Your program