问题遇到的现象和发生背景
跟着up主做的python简易版本呆呆鸟,跟着视频来的,但是执行只有背景
问题相关代码,请勿粘贴截图
from turtle import*
from random import randrange
from time import sleep
zhujue=[-100,80]
ball=[[240,0]]
zhujue_size=50
ball_size=80
def change():
zhujue[1]=zhujue[1]+zhujue_size
def distance(a,b,x,y):
return ((a - x) ** 2 + (b - y) ** 2) ** 0.5
def hit():
for n in range(len(ball)):
if distance(ball[n][0],ball[n][1],zhujue[0],zhujue[1])<(zhujue_size+ball_size)/2:
return True
return False
def inside():
if zhujue[1]<-300+zhujue_size/2 or zhujue[1]>300-zhujue_size/2:
return False
else:
return True
def draw():
clear()
for n in range(len(ball)):
######障碍#########
up()
goto(ball[n][0],ball[n][1])
dot(ball_size,'dark green')
ball[n][0]=ball[n][0]-3
up()
goto(zhujue[0],zhujue[1])
dot(zhujue_size,'blue')
zhujue[1]=zhujue[1]-5
update()
def gameloop():
if randrange(48)==1:
x=240
y=randrange(-300,300)
ball.append([x,y])
if len(ball)!=0:
if ball[0][0]<-220:
ball.pop
draw()
if (not inside()) or hit():
return
ontimer(gameloop,30)
setup(420,620,0,0)
hideturtle()
tracer(False)
bgcolor("light yellow")
listen()#监听函数
onkey(lambda: change()," ")
gameLoop()
done()
```(0)
###### 运行结果及报错内容
无报错内容,但运行不对