# Sparsh Pandey
# 23 Jun 2025
# Menu Screen for Maze (taken from game on 22 Jun 2025)

import pygame
import sys
import mazeScreen

# setup screen
pygame.init()
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Main Screen")

# add a font
font = pygame.font.SysFont(None, 40)

# Button setup
buttons = []
for i in range(3):
    buttons.append(pygame.Rect(50 + (WIDTH // 3) * i, 350, 150, 50))
button_labels = ["Play", "Options", "Quit"]

# Colors
BG_COLOR = (0, 0, 0)
BTN_COLOR = (70, 130, 180)
TEXT_COLOR = (255, 255, 255)

def draw():
    # fill screen
    screen.fill(BG_COLOR)

    # go through button list (enumerate gives me iterator and int for traversal of a list)
    for i, rect in enumerate(buttons):

        # draw button with text
        pygame.draw.rect(screen, BTN_COLOR, rect, border_radius=10)
        text = font.render(button_labels[i], True, TEXT_COLOR)
        text_rect = text.get_rect(center=rect.center)
        screen.blit(text, text_rect)
    pygame.display.update()

# Menu loop
while True:

    # just use our draw function :)
    draw()

    # get mouse input (can do what I did with playscrene as well, but wanted to show both)
    mx, my = pygame.mouse.get_pos()

    # get event
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()

        # mouse button down, so check if any button pressed
        if event.type == pygame.MOUSEBUTTONDOWN:

            # run the game
            if buttons[0].collidepoint(mx, my):
                mazeScreen.Game().run()

            # cheeky message
            if buttons[1].collidepoint(mx, my):
                print("You don't REEEEEALLLY need options...")

            # exit game
            if buttons[2].collidepoint(mx, my):
                pygame.quit()
                sys.exit()
