Skip to content Skip to sidebar Skip to footer

Multiple Bullets Pygame

I know there have been several topics on this but I still can't figure out how to make my robot shot multiple bullets... I want press my Space Button and shoot multiple bullets but

Solution 1:

Well, it will be tough to run that code without any of the images, but from what it looks like is you need a better way of tracking and updating the bullets. For example, the player class could have:

self.bullets = []

Then anytime you press space bar, you would add a new bullet:

new_bullet = Bullet()
# Set up x and y of bullet and such (could add them to the constructor)
man.bullets.append(Bullet())

Then anytime you need to update bullets, or draw them:

foreach bullet in man.bullets:
    bullet.x += .....
    bulett.y += .....
    # any additional updates and drawing and such

Post a Comment for "Multiple Bullets Pygame"