I'm trying to build a small game using Pygame where a user will move a helicopter up and down and press space bar to shoot bullets. I already have the bullet image installed into the program and set the starting X and Y using pygame.key.get_pressed
, but I'm trying to make it so multiple bullets can be shot across the screen at the same time. Here's the two parts of the code that deal with bullets that I have made, but they only have capacity for one bullet and when I press space again, the bullet just reappears and restarts it's motion.
pygame.key.get_pressed
...
if keys[pygame.K_SPACE]:
Bullet = pygame.image.load("Images/Bullet.png")
BulletX = HELICOPTERX
BulletY = HelicopterY + 15
BulletShoot = True
...
if BulletShoot == True:
BulletX += 5
SURF.blit(Bullet, (BulletX, BulletY))
if BulletX >= 800: #800 is the width of the screen
BulletShoot = False