AutoHotkey | Android | Arduino | COMM140 | Fractals | Grammar Checkers | Knots | A Million Dots Activity | Processing | Processing for Scratch Users | Redbubble | Tutorials | Weather | World Time Meeting Planner | Favicon Generator.
Home > MicroWorlds > Introduction to Turtle Graphics
MicroWorlds 2.0 User's Guide (77 Pages) 462KB
pd ;
pen down so the turtle |
|
|
|
fd 100 ; forward 100 |
|
setpensize 2 ;
draw with a
|
|
setpensize 5 ;
draw with a |
|
rt 90 ;
turn right 90 |
|
pd |
|
pd |
|
cg |
|
cg |
|
cg |
|
cg |
|
cg |
|
cg |
|
cg |
Note so far we have been typing commands one line at a time into the command center now we will look at typing commands into a procedure.
A procedure is a list of commands typed into the procedures page. All procedures start with the word to and end with the word end. Note all procedures must have unique names. eg to circle.
To switch to the procedures page select Pages
| Procedures
or use the keyboard shortcut CTRL + F
At first the procedures page will be blank
Copy a procedure from the example below or type your own.
;
Note these comments are only to help explain the program.
; You don't have
to type the comments for the program to work.
to
circle ;
start of a procedure called circle
repeat 360 [ ;
repeats all commands within the square ;
brackets [ ] n times
fd 1 ;
move forward one turtle step
rt 1 ;
right turn 1 degree
] ;
end of repeat
end ;
end of procedure
Close the procedures page by typing CTRL + F
Type the name of the procedure in the command center eg circle.
circle
The power of procedures comes from using one procedure again and again.
to circle
pd
repeat 180 [ fd 2 rt 2 ]
end
to torus
cg
repeat 36 [ circle rt 10 ] ; draw 36 circles each 10 degrees apart
end
to
circle ;
start of a procedure ;
called circle pd ; pen down repeat 360 [ ; repeats all commands ; within the square ; brackets n times fd 1 ; move forward one step rt 1 ; right turn 1 degree ] ; end of repeat end ; end of procedure |
|
to triangle
;
start of a procedure called ;
triangle pd ; pen down repeat 3 [ ; repeats all commands ; within the square ; brackets n times fd 200 ; move forward 200 turtle steps rt 120 ; right turn 120 degree ] ; end of repeat end ; end of procedure |
|
to square ;
start of a procedure called ; square pd ; pen down repeat 4 [ ; repeats commands n times fd 100 ; move forward 100 turtle steps rt 90 ; right turn 90 degrees ] ; end of repeat end ; end of procedure |
to octagon |
|
to polygon Note this procedure uses a slider named sides to change the number of sides in the polygon. |
Use a button to run a procedure or type the name of the procedure in the command center.
Use sliders to change the value of a variable within a procedure.
To insert a slider 1 click on the slider
tool 2 type the
name of the slider ~ sides ~
3 enter the Minimum: and Maximum:
vaues for the slider 4 click OK
APA citation:
Russell, R. (2016, July 04, 02:14 pm). Microworlds intro.
Retrieved November 22, 2024, from http://www.rupert.id.au/microworlds/intro.php
Last refreshed: November 22 2024. 06:24.10 pm
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.