Files
WarioWare-Black-and-WAH/engine/menu.py
T

57 lines
2.2 KiB
Python

import pygame
from engine.scene import Scene
from settings import *
from engine.utils import scale_to_fit
class Menu(Scene):
def __init__(self, manager):
super().__init__(manager)
self.wario_button = pygame.Rect(SCREEN_WIDTH // 4, SCREEN_HEIGHT // 2 - 50, SCREEN_WIDTH // 2, 100)
self.ninevolt_button = pygame.Rect(SCREEN_WIDTH // 4, SCREEN_HEIGHT // 2 + 100, SCREEN_WIDTH // 2, 100)
self.logo_image = None
self.logo_rect = None
try:
logo_path = resource_path("Assets/images/title/logo.png")
logo_image_raw = pygame.image.load(logo_path)
# Define a bounding box for the logo
logo_bounds = pygame.Rect(0, 0, SCREEN_WIDTH * 0.75, SCREEN_HEIGHT * 0.4)
logo_bounds.center = (SCREEN_WIDTH // 2, SCREEN_HEIGHT // 4)
self.logo_image, self.logo_rect = scale_to_fit(logo_image_raw, logo_bounds)
except (pygame.error, FileNotFoundError) as e:
print(f"Error loading title screen logo: {e}")
self.logo_image = None
def update(self, dt):
mouse_pos = pygame.mouse.get_pos()
mouse_pressed = pygame.mouse.get_pressed()
if mouse_pressed[0]:
if self.wario_button.collidepoint(mouse_pos):
self.manager.start_game('wario')
elif self.ninevolt_button.collidepoint(mouse_pos):
self.manager.start_game('ninevolt')
def draw(self, screen):
screen.fill(BLACK)
# Draw logo
if self.logo_image and self.logo_rect:
screen.blit(self.logo_image, self.logo_rect)
# Wario button
pygame.draw.rect(screen, BLACK, self.wario_button)
font = pygame.font.Font(None, 50)
text = font.render("Wario's Opposites Attack!", True, WHITE)
text_rect = text.get_rect(center=self.wario_button.center)
screen.blit(text, text_rect)
# 9-Volt button
pygame.draw.rect(screen, BLACK, self.ninevolt_button)
font = pygame.font.Font(None, 50)
text = font.render("9-Volt's Retro Reload", True, WHITE)
text_rect = text.get_rect(center=self.ninevolt_button.center)
screen.blit(text, text_rect)