In my game, there is a problem with bullet spamming, because the player can shoot a lot of bullets in a short time. How can I prevent the player to do that? Should I use a clock? And how can I use the clock? Here it is some code:
class Player (Obj):
def command (self, shoot):
keys = pg.key.get_pressed()
self.shoot = shoot
if keys[shoot]:
self.Shoot()
def Shoot(self):
global prts
prts.append (Ammo(player.x, player.y, prt_img ))
print (prts)
while True:
window.fill(WHITE)
player.blit()
player.command(pg.K_SPACE)
for ammo in prts:
ammo.blit()
ammo.Move(0.5)
ammo.BordCheck()
pg.display.update()
Here it is an image of what happens
Sorry for any mistakes