Using Images in Turtle programs

Today we’re excited to announce that you can customize your Python trinkets even further by using images in turtle programs! You can upload your own images and use them as the background of your scene or as a replacement for the shape of the turtle. Let’s jump right in and see an example:

Turtle Shape

We’ve added an image tab to the right of our code tabs. (Note that the plus icon for adding files is now a new file icon to match the new image icon.) The image tab shows us which images are available to use in this trinket. In the example below I uploaded a simple rocket ship image and added keyboard events to move my rocket ship around. Now, using the arrow keys, I can zoom around! There’s also an image of a car and a turtle. Change the value of the image variable to “car.png” or “turtle.png” and run the program again to see how other images look!


Now let’s change the background of our screen for another cool example. In the example below I uploaded an image of space and used screen.bgpic to set the background. I left the rocket ship in place and now we’re zooming through space!

Using images in turtle programs is sure to keep your students engaged as they continue their journey in learning to code.

This is just the beginning of the cool things you can do with this update. Here is an example of the Star Pusher game that Ben and Elliott collaborated on. (Go Fullscreen and be patient while it loads. It’s worth it!) It’s inspired by our friends at Invent with Python. Have fun playing and be sure to share with us your new turtle creations so we can feature them!

P.S. Expect a similar update in the near future that will allow you to upload images to your HTML trinkets!

6 thoughts on “Using Images in Turtle programs

  1. I’ve tried this. It does not work with .gif .jpg or .png but turtle shape itself yes!

Comments are closed.