Python pygame flapy bird随机管道生成
对于一个学校项目,我正在制作flappy bird,并尝试在管道到达某个点时随机生成管道,以获得新管道Python pygame flapy bird随机管道生成,python,pygame,Python,Pygame,对于一个学校项目,我正在制作flappy bird,并尝试在管道到达某个点时随机生成管道,以获得新管道 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
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
任何帮助都将不胜感激。您正在循环中重新分配
管道,隐藏您的def管道():
(这不是问题,但我们可以看到它是一个函数)
我建议将pipe
函数重命名为带有动词的函数,例如make_pipe()
您在循环中重新分配pipe
,隐藏def pipe():
(这不是问题,但我们可以看到它是一个函数)
我建议将pipe
函数重命名为带有动词的函数,例如make_pipe()
好的,我尝试更改for循环中的管道以生成_pipe,但现在它抛出了错误AttributeError:'list'对象没有属性'x'@JacksonPike显示您的新代码,包括make_pipe
函数。我无法将整个代码传递到中,但这里有两个链接。好的,我尝试在for循环中更改管道以生成_pipe,但现在它抛出错误AttributeError:“list”对象没有属性“x”@JacksonPike显示您的新代码,包括make_pipe
功能。我无法将整个代码放进去,但这里有一个链接。
obsitcal.append([pipe(start, -550, False), pipe(start , 300, True )])
TypeError: 'pipe' object is not callable