Oct-11-2018, 10:11 AM
G'day world,
So, I have a school assessment where we have to create a Flappy Bird game on Pygame. I am doing quite well so-far but I have came to a roadblock. When I generate the pipes, only the very last pipe becomes an object. I know why this is, but don't have a clue on how to fix it. I have tried putting them in lists but I get an error message. This is the code:
If anyone can help it would be greatly appreciated because I have been banging my head
trying to figure this out.
Thanks :)
So, I have a school assessment where we have to create a Flappy Bird game on Pygame. I am doing quite well so-far but I have came to a roadblock. When I generate the pipes, only the very last pipe becomes an object. I know why this is, but don't have a clue on how to fix it. I have tried putting them in lists but I get an error message. This is the code:
pipex = 600 pipesinfo = [] pipegap = 250 pipelast = 0 for something in range(10): direction = random.choice(["up", "down"]) if direction == "up": pipey = random.randint(250, 500) if direction == "down": pipey = random.randint(-500, -250) pipex = pipex + pipegap deff = (pipex, pipey, direction) pipesinfo.append(deff) #Show the pics screen.blit(background_image, (0, 0)) birdobj = screen.blit(bird, (birdx, birdy)) #pipeobj = [] #for pipex, pipey, direction in pipesinfo: # if direction == "down": # pipeobj = screen.blit(down, (pipex, pipey)) # elif direction == "up": # pipeobj = screen.blit(pipe, (pipex, pipey))The commented lines is where I feel the problem is. I think this because when ever it blits, it over rides the pipeobj object. (I think)
If anyone can help it would be greatly appreciated because I have been banging my head

Thanks :)