【发布时间】:2016-10-01 15:17:26
【问题描述】:
我是 python 的初学者,我编写了这段代码来使用 python turtle 制作弹跳球,但它会出现一些错误,比如球消失
import turtle
turtle.shape("circle")
xdir = 1
x = 1
y = 1
ydir = 1
while True:
x = x + 3 * xdir
y = y + 3 * ydir
turtle.goto(x , y)
if x >= turtle.window_width():
xdir = -1
if x <= -turtle.window_width():
xdir = 1
if y >= turtle.window_height():
ydir = -1
if y <= -turtle.window_height():
ydir = 1
turtle.penup()
turtle.mainloop()
【问题讨论】: