对于一个学校项目,我正在制作flappy bird,我试图让管道在管道到达某个piot时随机生成,以获得新管道。
top = [pipe(start, -550, False), pipe (start , 300, True )]
mid = [pipe(start , -400, False), pipe(start , 400, True)]
bod = [pipe(start, -300, False), pipe(start , 500, True)]
obsitcal = mid
def obsit(obsitcal):
for pipe in obsitcal:
if pipe.x <= 50:
pipenum = random.randint(1, 3)
if pipenum == 1:
obsitcal.append([pipe(start, -550, False), pipe(start , 300, True )])
elif pipenum == 2:
obsitcal = mid
elif pipenum == 3:
obsitcal = bod一旦管道到达应该生成新管道的点,游戏就会停止,并出现错误:
obsitcal.append([pipe(start, -550, False), pipe(start , 300, True )])
TypeError: 'pipe' object is not callable任何帮助都将不胜感激。
发布于 2020-03-05 14:27:32
您在循环中重新分配pipe,隐藏您的def pipe(): (这不在问题中,但我们可以看到它是一个函数)。
我建议将该pipe函数重命名为带动词的东西,例如make_pipe()。
https://stackoverflow.com/questions/60539277
复制相似问题