home—info—lects—labs—exams—hws
—D2L—breeze (snow day)—tutor/PIs
lab17-turtles
turtles!
turtle graphics; writing functions
Today in class we'll explore the JES menu item JES Functions > Turtles,
and together we'll
-
make a world
-
place a turtles into the world
-
have it move and turn
-
Add a second turtle into that same world, and have it move and turn.
-
The world can get cluttered and the turtles off in strange locations.
We find we're often making a new world and making a new turtle in that world.
make a function: newSandbox, which creates a world with a new turtle, and returns that turtle.
-
make a function: drawTriangle, which takes in a turtle and a size,
and has the turtle draw the triangle of the given size,
and leaves the turtle standing in its original position and direction.
-
Make a function drawTriangles, which takes in a turtle and a max-size,
and draws several triangles of different sizes:
the max-size, 75% of the max-size, 50% of the max-size, and 25% of the max-size.
TODO, today and next time:
-
Write a function drawSquare, which takes in a turtle and a size,
and has that turtle draw the square of the indicated size.
-
Write a function drawSquares, which behaves similarly to drawTriangles,
except it makes five squares sharing a vertex.
-
Make a function which takes in a turtle and a size, and has it draw a “zag” (like:
_/\_) where the size is the distance from the one tip to the other.
(Without trying, you'll leave the turtle at the end of the zag, pointing in the same direction
it started in.)
home—info—lects—labs—exams—hws
—D2L—breeze (snow day)—tutor/PIs