Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pygame flapy bird随机管道生成_Python_Pygame - Fatal编程技术网

Python pygame flapy 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

对于一个学校项目,我正在制作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








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