import pygame # initialize Pygame pygame.init() # set the window size window_size = (400, 600) # create the window screen = pygame.display.set_mode(window_size) # set the window title pygame.display.set_caption("Golf Game") # load the background image bg_image = pygame.image.load("bg.png") # list to store the strokes for each hole strokes = [] # number of holes in the course holes = 18 # loop through the holes for i in range(holes): # draw the background image screen.blit(bg_image, (0, 0)) # draw the hole number font = pygame.font.Font(None, 36) text = font.render(f"Hole {i+1}", True, (255, 255, 255)) screen.blit(text, (10, 10)) # update the display pygame.display.update() # wait for the player to hit a key waiting = True while waiting: for event in pygame.event.get(): if event.type == pygame.KEYDOWN: waiting = False # calculate the total score total_score = sum(strokes) # draw the total score font = pygame.font.Font(None, 36) text = font.render(f"Total score: {total_score}", True, (255, 255, 255)) screen.blit(text, (10, 10)) # update the display pygame.display.update() # wait for the player to close the window waiting = True while waiting: for event in pygame.event.get(): if event.type == pygame.QUIT: waiting = False # quit Pygame pygame.quit()