I have been trying to make it where if i press space when the program has already been launched it will play my song. It opens up, then i get the loading animation on my cursor(when cursor is over the program.).The programs crashed.
`import pygame, sys
from pygame.locals import *
bf = 'bg.jpg'
pygame.init()
screen = pygame.display.set_mode((800, 600))
background = pygame.image.load(bf) .convert()
screen.blit(background, (0,0))
pygame.display.update()
pygame.display.set_caption('Letters')
keys=pygame.key.get_pressed()
while True:
if keys[pygame.K_SPACE]:
pygame.mixer.music.load('ht.mp3')
pygame.mixer.music.play(loops=-1, start=0)
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
Please explain it me like I was a kid.(I am new in pygame.)