Submit a well-formatted pull request to our class blog with embedded Trinket programs for the below exercises. Complete these on your own, using any materials you need. Do not look at other students’ submissions until after you’ve completed your work.
After your programs are done, check other students’ work and other resources online if you had questions. Include a reflection about what you think you’ve learned and any concepts that are still fuzzy to you. Did you encounter frustrating situations? Did you feel a lightbulb turn on?
This is another open-ended turtlehack, but now you’ve got lots of tools in your toolkit. Take the weekend code an awesome program. Don’t forget your Problem Solving Attitudes and Strategies!
Write a turtle program that:
- Has a
setup()
function that sets up your screen visually. For instance, you could draw green grass and blue sky using the.fill()
method. I’ve created a second
Option 1: Clicks
- Uses the
screen.onclick()
function method to callclicky()
function you create - Within clicky, do something cool. Think outside the
.goto(x, y)
box :) - Within clicky, call one or more helper functions you’ve created
- Within clicky or helper functions, use logic to change your program’s behavior based on the turtle’s x and/or y coordinates. For instance, you could vary the turtle’s color, speed, or call different helper functions.
Option 2: Keys
- Listen for at least the 4 arrow keys and one more key to control the turtle’s position and one other aspect of its state.
-
Call a helper function in at least one of your click functions
- Uses lists, loops, and string methods
- Does one of the following:
- Allows the user to make something creative interactively
- Has a ‘win’ condition. Make sure to give instructions!
- Implements a narrative animation.
import time
,time.sleep(x)
andtina.clear()
will be useful if you pick this one.
If you’d like to stretch yourself, try these:
- Add other functions to
animations.py
, import them and use them in your main program. - Create a second turtle other than
tina
and have him/her also do something in your clicky function. - Explore the
screen.update()
andscreen.tracer()
methods to change how often the screen updates and fix the zigzag artifacts. - Add your own new module (i.e.
mymodule.py
) andimport
something from it. You could even put your clicky function there to keep your code clean and readable.
Option 1 Starter
Use this Clicky starter code unless you feel like coding from scratch: