Update test.py
parent
0e2b74295c
commit
ad12f18b3b
16
test.py
16
test.py
|
@ -29,6 +29,8 @@ pygame.display.set_caption("Танчики")
|
|||
pygame.mixer.music.load('music.mp3')
|
||||
pygame.mixer.music.play(-1) # Параметр -1 означает зацикливание музыки
|
||||
shot_sound = pygame.mixer.Sound('shot.wav')
|
||||
meme_sound = pygame.mixer.Sound("meme_sound.wav")
|
||||
|
||||
|
||||
|
||||
# Загрузка изображений
|
||||
|
@ -282,6 +284,10 @@ def respawn_bot():
|
|||
all_sprites.add(new_bot)
|
||||
tanks.add(new_bot)
|
||||
|
||||
last_meme_time = 0
|
||||
meme_delay = 2000 # Задержка в миллисекундах (2 секунды)
|
||||
|
||||
|
||||
|
||||
# Главный цикл программы
|
||||
menu_active = True
|
||||
|
@ -307,12 +313,22 @@ while running:
|
|||
player_bullets = []
|
||||
bot_bullets = []
|
||||
|
||||
current_time = pygame.time.get_ticks()
|
||||
|
||||
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
elif event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: # Обработка левой кнопки мыши
|
||||
player.shoot()
|
||||
|
||||
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_k:
|
||||
if current_time - last_meme_time > meme_delay: # Проверка задержки
|
||||
meme_sound.play()
|
||||
last_meme_time = current_time # Обновление времени последнего воспроизведения звука
|
||||
|
||||
# Обновление всех спрайтов
|
||||
all_sprites.update()
|
||||
|
||||
|
|
Loading…
Reference in New Issue