【发布时间】:2021-11-23 07:41:45
【问题描述】:
所以我试图从乒乓球程序中汲取灵感,制作一个迷宫程序。一切都很好,直到乌龟摔断了。 python 版本是 3.9.7,下面是代码,以及运行代码产生的窗口截图。
import turtle
#Screen: Should be 800 X 600 box, with blue background, and a title of "Test"
wn = turtle.Screen()
wn.title("Test")
wn.bgcolor("blue")
wn.setup(width=800, height=600)
wn.tracer(0)
#Simple character/shape, square, red.
character = turtle.Turtle()
character.speed(0)
character.shape("square")
character.color("red")
character.penup()
character.goto(0, 0)
#main loop
turtle.mainloop()
下面是窗口的图片。如您所见,字符从 0、0 中丢失。我该如何解决这个问题?代码有问题吗?我必须重新安装一些东西吗? [1]:https://i.stack.imgur.com/LMclH.png
【问题讨论】:
-
删除
tracer()电话,你会看到你的角色。在您的代码基本正常工作之前,请不要再使用tracer()和update()。
标签: python python-3.x turtle-graphics python-turtle