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!

Background

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!

  • Sam Beer

    hi is there any way i can implement this into my own python work

  • Drew Wilkerson

    Thank you

  • Stephen Wilkerson

    Unfortunately it does not work, you’ve left something out..