From ebeef03971cac7d000d5b9ed2ea60d25b1289be3 Mon Sep 17 00:00:00 2001 From: Timofejs Maksimovs Date: Mon, 4 Mar 2024 07:55:42 +0000 Subject: [PATCH] Update menu copy 2.py --- menu copy 2.py | 53 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/menu copy 2.py b/menu copy 2.py index 769b5b3..0de716e 100644 --- a/menu copy 2.py +++ b/menu copy 2.py @@ -1,37 +1,53 @@ -import pygame, sys -from button import Button import pygame +import sys +from button import Button # Assuming you have a Button class defined in a separate file from random import randint import math pygame.init() -SCREEN = pygame.display.set_mode((1280, 720)) +SCREEN_WIDTH = 1280 +SCREEN_HEIGHT = 720 +SCREEN = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT)) pygame.display.set_caption("Rouglite") +# Loading images and music BG = pygame.image.load("assets/Background.png") +LD = pygame.transform.scale(pygame.image.load("Sprites/loading.png").convert(), (SCREEN_WIDTH, SCREEN_HEIGHT)) + pygame.mixer.music.load('assets/Pixel 7.mp3') - -# Воспроизведение музыки -pygame.mixer.music.play() - -# Добавьте какую-то задержку, чтобы музыка воспроизводилась в течение некоторого времени -pygame.time.delay(5000) # Например, 5000 миллисекунд (5 секунд) - +# Define fonts def get_font(size): # Returns Press-Start-2P in the desired size return pygame.font.Font("assets/font.ttf", size) +def show_loading_screen(): + start_time = pygame.time.get_ticks() + loading_image_rect = LD.get_rect(center=(SCREEN_WIDTH // 2, SCREEN_HEIGHT // 2)) + pygame.mouse.set_visible(False) # Hide the cursor + while True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit() + sys.exit() + + SCREEN.fill((0, 0, 0)) + SCREEN.blit(LD, loading_image_rect) # Display the loading image + pygame.display.update() + if pygame.time.get_ticks() - start_time >= 5000: + pygame.mouse.set_visible(True) # Show the cursor + return + + +# Display loading screen for 5 seconds before showing main menu +show_loading_screen() + def play(): while True: pygame.time.delay(500) import Game_V2 -# Game_V2 vietāpievienojiet failu ar pabeigto spēli - - - + # Game_V2 vietāpievienojiet failu ar pabeigto spēli - def options(): volume = 1 # Initial volume slider_height = 20 # Slider height @@ -40,8 +56,6 @@ def options(): 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) @@ -94,9 +108,6 @@ def options(): pygame.display.update() - - - def main_menu(): while True: SCREEN.blit(BG, (0, 0)) @@ -134,4 +145,4 @@ def main_menu(): pygame.display.update() -main_menu() \ No newline at end of file +main_menu()