设置图像蟒蛇龟的位置

时间:2016-12-26 17:46:31

标签: python turtle-graphics

我添加了相关代码的图像。我的挑战是设置一个理想的图像位置。默认位置是画布的中心,如何更改,请帮助。 谢谢

1 个答案:

答案 0 :(得分:0)

假设你已经加载了一些* .gif图像作为海龟的图像,那么你可以在画布上随心所欲地turtle.goto()(或turtle.setposition()等)并将turtle.stamp()图片留在后面:

from turtle import Turtle, Screen

# https://cdn-img.easyicon.net/png/10757/1075705.gif

SQUIRREL_IMAGE = '1075705.gif'

screen = Screen()

screen.register_shape(SQUIRREL_IMAGE)

turtle = Turtle(shape=SQUIRREL_IMAGE)
turtle.penup()

turtle.goto(100, 100)
turtle.stamp()
turtle.goto(-100, -100)
turtle.stamp()

turtle.hideturtle()

screen.exitonclick()

<强>输出

enter image description here

相关问题