How can I import an image in Python Turtle?

前端 未结 5 1733
时光说笑
时光说笑 2021-01-24 10:47

What I want, is to get an image to replace the default turtle, just like it is done here: http://blog.trinket.io/using-images-in-turtle-programs/ .

This is my code, but

5条回答
  •  爱一瞬间的悲伤
    2021-01-24 11:25

    You can take screenshot of the pic and can convert/resize to .gif at ezgif.com.

    Background:

    win = turtle.Screen()
    win.bgpic('background.gif') or whatever the file name in the directory.
    

    Using Shapes:

    win.register_shape('pic1.gif')
    rocket = turtle.Turtle()
    rocket.shape('pic1.gif')
    

    Simple example game:

    https://www.youtube.com/watch?v=sRnSJvSHgBs&t=4s

提交回复
热议问题