From eebc489d4ff7b573c6a6331307eb46785e91d6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C4=81ns=20=C5=A0aduncs?= Date: Sat, 2 Mar 2024 21:39:07 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20menu=20copy=202.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu copy 2.py | 268 ++++++++++++++++++++++++------------------------- 1 file changed, 134 insertions(+), 134 deletions(-) diff --git a/menu copy 2.py b/menu copy 2.py index 994d918..9281b4e 100644 --- a/menu copy 2.py +++ b/menu copy 2.py @@ -1,135 +1,135 @@ -import pygame, sys -from button import Button -import pygame -from random import randint -import math - -pygame.init() - -SCREEN = pygame.display.set_mode((1280, 720)) -pygame.display.set_caption("Menu") - -BG = pygame.image.load("assets/Background.png") -pygame.mixer.music.load('assets/Pixel 10.mp3') - -# Воспроизведение музыки -pygame.mixer.music.play() - -# Добавьте какую-то задержку, чтобы музыка воспроизводилась в течение некоторого времени -pygame.time.delay(5000) # Например, 5000 миллисекунд (5 секунд) - -def get_font(size): # Returns Press-Start-2P in the desired size - return pygame.font.Font("assets/font.ttf", size) - -def play(): - while True: - import Movement_version_3 -# Movement_version_3 vietāpievienojiet failu ar pabeigto spēli - - - - - -def options(): - volume = 1 # Initial volume - slider_height = 20 # Slider height - - while True: - SCREEN.blit(BG, (0, 0)) - OPTIONS_MOUSE_POS = pygame.mouse.get_pos() - - - - OPTIONS_TEXT = get_font(45).render("Change Volume", True, "white") - OPTIONS_RECT = OPTIONS_TEXT.get_rect(center=(640, 260)) - SCREEN.blit(OPTIONS_TEXT, OPTIONS_RECT) - - # Volume slider - - pygame.draw.rect(SCREEN, "gray", (500, 330, 200, slider_height)) # Slider background - - # Calculate slider width based on volume level - slider_width = int(volume * 200) - slider_color = (62, 74, 49) # Green color - if volume < 1: - slider_color = (0, 255 * (1 - volume), 0) # Decrease green component based on volume level - pygame.draw.rect(SCREEN, slider_color, (500, 330, slider_width, slider_height)) # Actual slider - - # Draw "+" and "-" symbols - plus_text = get_font(30).render("+", True, "#5c3938") - minus_text = get_font(30).render("-", True, "#5c3938") - plus_rect = plus_text.get_rect(center=(715, 330 + slider_height // 2)) - minus_rect = minus_text.get_rect(center=(485, 330 + slider_height // 2)) - SCREEN.blit(plus_text, plus_rect) - SCREEN.blit(minus_text, minus_rect) - - # BACK button - OPTIONS_BACK = Button(image=None, pos=(640, 460), - text_input="BACK", font=get_font(75), base_color="#5c3938", hovering_color="White") - - OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS) - OPTIONS_BACK.update(SCREEN) - - for event in pygame.event.get(): - if event.type == pygame.QUIT: - pygame.quit() - sys.exit() - if event.type == pygame.MOUSEBUTTONDOWN: - if OPTIONS_BACK.checkForInput(OPTIONS_MOUSE_POS): - main_menu() - # Check if mouse click is on minus symbol - if minus_rect.collidepoint(event.pos): - volume -= 0.1 - if volume < 0: - volume = 0 - pygame.mixer.music.set_volume(volume) # Set the volume of the music - # Check if mouse click is on plus symbol - if plus_rect.collidepoint(event.pos): - volume += 0.1 - if volume > 1: - volume = 1 - pygame.mixer.music.set_volume(volume) # Set the volume of the music - - pygame.display.update() - - - - -def main_menu(): - while True: - SCREEN.blit(BG, (0, 0)) - - MENU_MOUSE_POS = pygame.mouse.get_pos() - - MENU_TEXT = get_font(100).render("Roguelite", True, "white") - MENU_RECT = MENU_TEXT.get_rect(center=(640, 100)) - - PLAY_BUTTON = Button(image=pygame.image.load("assets/Play Rect.png"), pos=(640, 250), - text_input="PLAY", font=get_font(75), base_color="#5c3938", hovering_color="White") - OPTIONS_BUTTON = Button(image=pygame.image.load("assets/Options Rect.png"), pos=(640, 400), - text_input="OPTIONS", font=get_font(75), base_color="#5c3938", hovering_color="White") - QUIT_BUTTON = Button(image=pygame.image.load("assets/Quit Rect.png"), pos=(640, 550), - text_input="QUIT", font=get_font(75), base_color="#5c3938", hovering_color="White") - - SCREEN.blit(MENU_TEXT, MENU_RECT) - - for button in [PLAY_BUTTON, OPTIONS_BUTTON, QUIT_BUTTON]: - button.changeColor(MENU_MOUSE_POS) - button.update(SCREEN) - - for event in pygame.event.get(): - if event.type == pygame.QUIT: - pygame.quit() - sys.exit() - if event.type == pygame.MOUSEBUTTONDOWN: - if PLAY_BUTTON.checkForInput(MENU_MOUSE_POS): - play() - if OPTIONS_BUTTON.checkForInput(MENU_MOUSE_POS): - options() - if QUIT_BUTTON.checkForInput(MENU_MOUSE_POS): - pygame.quit() - sys.exit() - - pygame.display.update() - +import pygame, sys +from button import Button +import pygame +from random import randint +import math + +pygame.init() + +SCREEN = pygame.display.set_mode((1280, 720)) +pygame.display.set_caption("Menu") + +BG = pygame.image.load("assets/Background.png") +pygame.mixer.music.load('assets/Pixel 7.mp3') + +# Воспроизведение музыки +pygame.mixer.music.play() + +# Добавьте какую-то задержку, чтобы музыка воспроизводилась в течение некоторого времени +pygame.time.delay(5000) # Например, 5000 миллисекунд (5 секунд) + +def get_font(size): # Returns Press-Start-2P in the desired size + return pygame.font.Font("assets/font.ttf", size) + +def play(): + while True: + import Movement_version_3 +# Movement_version_3 vietāpievienojiet failu ar pabeigto spēli + + + + + +def options(): + volume = 1 # Initial volume + slider_height = 20 # Slider height + + while True: + SCREEN.blit(BG, (0, 0)) + OPTIONS_MOUSE_POS = pygame.mouse.get_pos() + + + + OPTIONS_TEXT = get_font(45).render("Change Volume", True, "white") + OPTIONS_RECT = OPTIONS_TEXT.get_rect(center=(640, 260)) + SCREEN.blit(OPTIONS_TEXT, OPTIONS_RECT) + + # Volume slider + + pygame.draw.rect(SCREEN, "gray", (500, 330, 200, slider_height)) # Slider background + + # Calculate slider width based on volume level + slider_width = int(volume * 200) + slider_color = (62, 74, 49) # Green color + if volume < 1: + slider_color = (0, 255 * (1 - volume), 0) # Decrease green component based on volume level + pygame.draw.rect(SCREEN, slider_color, (500, 330, slider_width, slider_height)) # Actual slider + + # Draw "+" and "-" symbols + plus_text = get_font(30).render("+", True, "#5c3938") + minus_text = get_font(30).render("-", True, "#5c3938") + plus_rect = plus_text.get_rect(center=(715, 330 + slider_height // 2)) + minus_rect = minus_text.get_rect(center=(485, 330 + slider_height // 2)) + SCREEN.blit(plus_text, plus_rect) + SCREEN.blit(minus_text, minus_rect) + + # BACK button + OPTIONS_BACK = Button(image=None, pos=(640, 460), + text_input="BACK", font=get_font(75), base_color="#5c3938", hovering_color="White") + + OPTIONS_BACK.changeColor(OPTIONS_MOUSE_POS) + OPTIONS_BACK.update(SCREEN) + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + if event.type == pygame.MOUSEBUTTONDOWN: + if OPTIONS_BACK.checkForInput(OPTIONS_MOUSE_POS): + main_menu() + # Check if mouse click is on minus symbol + if minus_rect.collidepoint(event.pos): + volume -= 0.1 + if volume < 0: + volume = 0 + pygame.mixer.music.set_volume(volume) # Set the volume of the music + # Check if mouse click is on plus symbol + if plus_rect.collidepoint(event.pos): + volume += 0.1 + if volume > 1: + volume = 1 + pygame.mixer.music.set_volume(volume) # Set the volume of the music + + pygame.display.update() + + + + +def main_menu(): + while True: + SCREEN.blit(BG, (0, 0)) + + MENU_MOUSE_POS = pygame.mouse.get_pos() + + MENU_TEXT = get_font(100).render("Roguelite", True, "white") + MENU_RECT = MENU_TEXT.get_rect(center=(640, 100)) + + PLAY_BUTTON = Button(image=pygame.image.load("assets/Play Rect.png"), pos=(640, 250), + text_input="PLAY", font=get_font(75), base_color="#5c3938", hovering_color="White") + OPTIONS_BUTTON = Button(image=pygame.image.load("assets/Options Rect.png"), pos=(640, 400), + text_input="OPTIONS", font=get_font(75), base_color="#5c3938", hovering_color="White") + QUIT_BUTTON = Button(image=pygame.image.load("assets/Quit Rect.png"), pos=(640, 550), + text_input="QUIT", font=get_font(75), base_color="#5c3938", hovering_color="White") + + SCREEN.blit(MENU_TEXT, MENU_RECT) + + for button in [PLAY_BUTTON, OPTIONS_BUTTON, QUIT_BUTTON]: + button.changeColor(MENU_MOUSE_POS) + button.update(SCREEN) + + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + if event.type == pygame.MOUSEBUTTONDOWN: + if PLAY_BUTTON.checkForInput(MENU_MOUSE_POS): + play() + if OPTIONS_BUTTON.checkForInput(MENU_MOUSE_POS): + options() + if QUIT_BUTTON.checkForInput(MENU_MOUSE_POS): + pygame.quit() + sys.exit() + + pygame.display.update() + main_menu() \ No newline at end of file