I'm making a game where a spaceship shoots at aliens. The problem is that when I call the shoot function twice I don't get two projectiles, but one get destroyed. I think I have to store the two projectiles in the same variable, but I don't know how to do that. Here it is some code:
class Obj :
def __init__ (self, x, y, img):
self.x = x
self.y = y
self.img = img
def blit (self):
window.blit (self.img, (self.x, self.y))
class Player (Obj):
def command (self, up, down, shoot):
keys = pg.key.get_pressed()
self.up = up
self.down = down
self.shoot = shoot
if keys[up]:
self.y -= 1
if keys[down]:
self.y += 1
if keys[shoot]:
self.Shoot()
def Shoot(self):
global Prt
Prt = Ammo(self.x, self.y, prt_img)
Prt.blit()
Prt.Move(0.5)