-
Notifications
You must be signed in to change notification settings - Fork 32
Purogo MyFirstDrawing
For our first drawing let's make a 2-dimensional square. Here is our first program to enter and save as 'square1':
turtle("simple square") do
forward 5
turnright 90
forward 5
turnright 90
forward 5
turnright 90
forward 5
end
Run this (/draw square) a few times before moving on (see Purogo/DrawingAndUndrawing).
Let's break this program down by the unique lines in the program. The first line indicates we want to start a turtle session called 'simple square':
turtle("simple square") do
Remember in ruby all 'do' statements must end in an 'end':
end
which we see at the bottom. The second line is 'forward 5'. Remember when we ran this we saw a square drawn on the ground with all sides being 5 blocks long? 'forward 5' represents each of those sides. It tells the creature to change the next 5 blocks it encounters into :wood. The other command we see is 'turnright 90'. This command will make the orientation of the chicken shift 90 degrees to the right. By reading down this turtle session you can see how we arrived at a square on the ground. This script seems repetitive doesn't it? Let's deal with that in the next session Purogo/ReducingRepetitionWithRuby.