import pygame import random Define the screen dimensions SCREENWIDTH = 1500 SCREENHEIGHT…
- User
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}, "Blueface": {"Image":"./fotos/Blueface/Blueface_1.jpeg", "listeners": 4890312}, "Bobby Shmurda": {"Image":"./fotos/Bobby_Shmurda/Bobby Shmurda_1_.jpeg", "listeners": 2523069}, "Cardi B": {"Image":"./fotos/Cardi_B/Cardi B_1.jpeg", "listeners": 30319082}, "Central Cee": {"Image":"./fotos/Central_Cee/Central Cee_1.jpeg", "listeners": 22520846}, "Chief Keef": {"Image":"./fotos/Chief_Keef/Chief Keef_1.jpeg", "listeners": 9541580},}
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
while True: # Select two random artists first_artist, second_artist = random.sample(list(artists.keys()), 2)
# 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)) # Define the desired width and height for the images image_width = 800 image_height = 600 # Blit the artist names screen.blit(first_artist_text, (0, image_height)) screen.blit(second_artist_text, (SCREEN_WIDTH // 2, image_height)) # 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() # 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)) # Clear the screen screen.fill(BLACK) # Display the images screen.blit(first_artist_image, (0, 0)) screen.blit(second_artist_image, (SCREEN_WIDTH // 2, 0)) - Assistant
The names of the artists are not written under the images because the code to blit the artist names onto the screen is placed before the code to load and display the images. This means that the images are covering up the text surfaces for the artist names.
To fix this, you can simply move the code to blit the artist names after the code to display the images. Here's the modified code:
while True: # Select two random artists first_artist, second_artist = random.sample(list(artists.keys()), 2) # Define the desired width and height for the images image_width = 800 image_height = 600 # 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() # 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)) # Blit the artist names screen.blit(first_artist_text, (0, image_height)) screen.blit(second_artist_text, (SCREEN_WIDTH // 2, image_height)) # Clear the screen screen.fill(BLACK) # Update the display pygame.display.flip() # Rest of the code...
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.