Jackson Pike
Jackson Pike

Reputation: 53

pygame flapy bird random pipe generation

for a school project, I am making flappy bird and i am trying to make the pipes randomly generate once the pipe reaches a certain piot to get a new pipe.

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

once the pipe reaches the point where a new pipe should be generated the game stops and the error:

 obsitcal.append([pipe(start, -550, False), pipe(start , 300, True )])

TypeError: 'pipe' object is not callable

any help would be appreciated.

Upvotes: 1

Views: 360

Answers (1)

AKX
AKX

Reputation: 169318

You're reassigning pipe in the loop, shadowing your def pipe(): (which isn't in the question, but we can see it's a function).

I'd recommend renaming that pipe function to something with a verb, e.g. make_pipe().

Upvotes: 3

Related Questions