From da2edc7634ff838d0a552df7f86fb84df9278baa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artjoms=20Marians=20=C5=85e=C4=8Dajevs?= Date: Sat, 2 Mar 2024 16:37:39 +0000 Subject: [PATCH] Update Gaame with menu --- Gaame with menu | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/Gaame with menu b/Gaame with menu index f109700..054f585 100644 --- a/Gaame with menu +++ b/Gaame with menu @@ -261,8 +261,6 @@ bot = Bot(3 * SCREEN_WIDTH // 4, SCREEN_HEIGHT // 2) all_sprites.add(bot) tanks.add(bot) -music_enabled = True - def draw_menu(): screen.blit(menu_background, (0, 0)) # Рисуем текст меню @@ -276,31 +274,9 @@ def draw_menu(): quit_rect = quit_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 50)) screen.blit(quit_text, quit_rect) - # Рисуем кнопку включения/выключения музыки - music_text = font.render("Music: " + ("On" if music_enabled else "Off"), True, WHITE) - music_rect = music_text.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2 + 150)) - screen.blit(music_text, music_rect) - pygame.display.flip() - return quit_rect, music_rect # Возвращаем прямоугольники для кнопок "Выйти" и "Музыка" - -# Главный цикл программы -menu_active = True -while menu_active: - quit_rect, music_rect = draw_menu() - for event in pygame.event.get(): - if event.type == pygame.MOUSEBUTTONDOWN: - if event.button == 1: # Левая кнопка мыши - if quit_rect.collidepoint(event.pos): - pygame.quit() - quit() - elif music_rect.collidepoint(event.pos): # Проверяем, нажата ли кнопка музыки - music_enabled = not music_enabled # Инвертируем состояние звука - if music_enabled: - pygame.mixer.music.unpause() # Включаем музыку - else: - pygame.mixer.music.pause() # Выключаем музыку + return quit_rect # Возвращаем прямоугольник для кнопки "Выйти" @@ -527,9 +503,8 @@ while running: screen.blit(stenki, (1600, 1030)) screen.blit(stenki, (1800, 1030)) - pygame.display.flip() clock.tick(FPS) # Завершение работы Pygame -pygame.quit() +pygame.quit() \ No newline at end of file