# Maria Mauco
# 6/18/24
# Main function

import pygame, sys
from pygame.locals import *
import random
import mariogame
import marioscores

pygame.init()
clock = pygame.time.Clock()
pygame.display.set_caption("Bad Mario Main Menu")

# Create Font objects
font = pygame.font.SysFont(None, 36)
bigfont = pygame.font.SysFont(None, 52)

# Menu function

def menu():
    
    MAXSCORE = 10

    while True:
        screen = pygame.display.set_mode((mariogame.SCREEN_W, mariogame.SCREEN_H))
        screen.fill("white")
        mx = pygame.mouse.get_pos()[0]
        my = pygame.mouse.get_pos()[1]

        mariogame.draw("Menu", bigfont, "black", screen, 450, 20)

        # Three buttons for three choices
        buttons = []
        buttons.append(pygame.Rect(300,100,400,100))
        buttons.append(pygame.Rect(300,250,400,100))
        buttons.append(pygame.Rect(300,400,400,100))

        for button in buttons:
            pygame.draw.rect(screen,"cyan", button)

        # Draws text on buttons
        mariogame.draw("Play Bad Mario", font, "black", screen, 400, 135)
        mariogame.draw("See High Scores", font, "black", screen, 410, 285)
        mariogame.draw("Quit", font, "black", screen, 480, 435)

        # Get events from the queue
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()

            if event.type == MOUSEBUTTONDOWN:
                if event.button == 1: # if the button was the left click
                    if buttons[0].collidepoint((mx,my)):
                        score = mariogame.maingame(MAXSCORE)
                        if score > MAXSCORE:
                            MAXSCORE = score
                    if buttons[1].collidepoint((mx,my)):
                        marioscores.show(MAXSCORE)
                    if buttons[2].collidepoint((mx,my)):
                        pygame.quit()
                        sys.exit()

        pygame.display.update()
        clock.tick(30)

menu()
                    
        


        
