I'm trying to run the following code:
import pygame
WIDTH, HEIGHT = 800, 500
FPS = 60
DR_RUIN_WIDTH, DR_RUIN_HEIGHT = 800, 1200
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Dr. Ruin Rap Performance")
BG = pygame.transform.scale(pygame.image.load("files/bg.png"), (WIDTH, HEIGHT)).convert()
DR_RUIN_IMAGE = pygame.image.load("files/drruinsprite.png")
DR_RUIN = pygame.transform.scale(DR_RUIN_IMAGE, (DR_RUIN_WIDTH, DR_RUIN_HEIGHT))
DR_RUIN_BACK_IMAGE = pygame.image.load("files/drruinspriteback.png")
DR_RUIN_BACK = pygame.transform.scale(DR_RUIN_BACK_IMAGE, (DR_RUIN_WIDTH, DR_RUIN_HEIGHT))
BLUE = "#7c15ea"
def draw_window():
WIN.blit(BG, (0, 0))
WIN.blit(DR_RUIN, (15, -275))
pygame.draw.rect(WIN, BLUE, pygame.Rect(0, 450, 800, 50))
pygame.display.update()
pygame.time.delay(14000)
WIN.blit(DR_RUIN_BACK, (15, -275))
pygame.display.update()
pygame.time.delay(1000)
WIN.blit(DR_RUIN, (15, -275))
pygame.display.update()
def main():
clock = pygame.time.Clock()
run = True
while run:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
break
draw_window()
pygame.quit()
exit()
if __name__ == "__main__":
pygame.mixer.init()
song = pygame.mixer.Sound("files/ruinsong (2).mp3")
pygame.mixer.music.set_volume(0.7)
song.play()
main()
When I try to exit the program while it's running, the window isn't responding and a message pops up informing me that the window isn't responding. It also happens when I spam click on the window. Can someone please help me fix this?