I have problem with my code:
for event in pygame.event.get():
if event.type == pygame.QUIT:
continuer = False
pygame.quit()
elif event.type == pygame.KEYDOWN:
if (event.key == pygame.K_a):
game.sound.play('zawarudo')
time.sleep(2)
for game.ennemy in game.all_ennemy:
game.ennemy.velocity = 0
time.sleep(5)
game.ennemy.velocity = 2
When I pressed the key A, the loop "for" is executed immediately, not after 2s . Also, my game freeze and control doesn't work during the sleep function (2s).
The Goal of this code is simple. When I pressed the key A, a song is played and, after 2s, the loop begin. After 5s of waiting, the loop end.
How I can make a wait function with no game freezing, and functional.
Thanks.