import pygame
import random

# Define the screen dimensions
SCREEN_WIDTH = 1500
SCREEN_HEIGHT = 800

# Define the colors
BLACK = (0, 0, 0)

# Define the artists and their monthly Spotify listeners
artists = {

    "$NOT": {"Image":"./fotos/$NOT/$NOT_1.jpeg", "listeners": 7781046},

    "21 Savage": {"Image":"./fotos/21_Savage/21 Savage_1.jpeg", "listeners": 60358167},

    "9lokknine": {"Image":"./fotos/9lokknine/9lokknine_1.jpeg", "listeners": 1680245},

    "A Boogie Wit Da Hoodie": {"Image":"./fotos/A_Boogie_Wit_Da_Hoodie/A Boogie Wit Da Hoodie_1.jpeg", "listeners": 18379137},

    "Ayo & Teo": {"Image":"./fotos/Ayo_&_Teo/Ayo & Teo_1.jpeg", "listeners": 1818645},

    "Bhad Bhabie": {"Image":"./fotos/Bhad_Bhabie/Bhad Bhabie_1.jpeg", "listeners": 1915352},
}

# Initialize the game
pygame.init()

# Define the font and font size for the artist names
font = pygame.font.Font(None, 36)

# Initialize the font module
pygame.font.init()

# Initialize the game window and caption
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Guess the Artist")

# Create a clock object to control the frame rate
clock = pygame.time.Clock()

score = 0

# Game loop
running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # Select two random artists
    first_artist, second_artist = random.sample(list(artists.keys()), 2)

    # Load the images for the artists
    first_artist_image = pygame.image.load(artists[first_artist]["Image"]).convert()
    second_artist_image = pygame.image.load(artists[second_artist]["Image"]).convert()

    # Define the desired width and height for the images
    image_width = 800
    image_height = 600

    # Resize the first artist's image
    first_artist_image = pygame.transform.scale(first_artist_image, (image_width, image_height))

    # Resize the second artist's image
    second_artist_image = pygame.transform.scale(second_artist_image, (image_width, image_height))

    # Display the images
    screen.blit(first_artist_image, (0, 0))
    screen.blit(second_artist_image, (SCREEN_WIDTH // 2, 0))

    # Render the text surfaces for the artist names
    first_artist_text = font.render(f"1 - {first_artist.title()}", True, (255, 255, 255))
    second_artist_text = font.render(f"2 - {second_artist.title()}", True, (255, 255, 255))

    # Calculate the x-coordinate for centering the text surfaces
    first_artist_x = (image_width - first_artist_text.get_width()) // 2
    second_artist_x = (image_width - second_artist_text.get_width()) // 2 + SCREEN_WIDTH // 2

    # Blit the artist names
    screen.blit(first_artist_text, (first_artist_x, image_height))
    screen.blit(second_artist_text, (second_artist_x, image_height))

    # Update the display
    pygame.display.flip()

    # Clear the screen
    screen.fill(BLACK)

    # Prompt the player for their guess
    guess = input(f"\nWhich artist has more monthly Spotify listeners - 1. {first_artist.title()} or 2. {second_artist.title()}? ")
    guess_lower = guess.strip().lower()

    if guess_lower == 'quit':
        print("Thanks for playing!")
        running = False
    elif guess_lower not in ['1', '2', first_artist.lower(), second_artist.lower()]:
        print("Invalid input. Please enter the name of one of the two artists or 'quit' to end the game.")
    elif guess_lower == first_artist.lower() or guess_lower == '1' and artists[first_artist]["listeners"] > artists[second_artist]["listeners"]:
        print(f"You guessed correctly! {first_artist.title()} had {artists[first_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners and {second_artist.title()} has {artists[second_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners.")
        score += 1
    elif guess_lower == second_artist.lower() or guess_lower == '2' and artists[second_artist]["listeners"] > artists[first_artist]["listeners"]:
        print(f"You guessed correctly! {second_artist.title()} had {artists[second_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners and {first_artist.title()} has {artists[first_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners.")
        score += 1
    else:
        print(f"\nSorry, you guessed incorrectly. {first_artist.title()} had {artists[first_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners and {second_artist.title()} has {artists[second_artist]['listeners'] / 1e6:.1f}M monthly Spotify listeners.\n")
        print(f"Your current score is {score}.")

        # Ask the player if they want to play again
        play_again = input("Would you like to play again? (y/n) ")
        if play_again.lower() == 'n':
            print(f"Your final score is {score}. Thanks for playing!")


pygame.quit()
how can i make the whole game happen in the pygame window