-
Notifications
You must be signed in to change notification settings - Fork 33
Purogo MakingNamedBlocks
Let's make our last asterisk example more funky and make the lines dashed like we made a dashed line earlier. Name this drawing 'dashed_asterisk':
turtle("dashed asterisk") do |*args|
length = (args[0] or 10).to_i
dashed_line do
(length / 2).times do
block :sandstone
forward 1
block :none
forward 1
end
end
mark "center"
8.times do |i|
turnright i*45
dashed_line
goto "center"
end
endAt any point you can make a named block by giving a name ('dashed_line') followed by a do...end block. This ends up reserving the name in your drawing for later recall. The contents between the do and end will be executed whenever your drawing later encounters the name of the named block. In the example above, we now have a named block for drawing a dashed line. The only change from the previous version of asterisk is that instead of calling 'forward length' we are now calling 'dashed_line'. If you run this you will see we now have a funky asterisk. We may have enough tools now to start our first Purogo-MyFirst3DDrawing.