So I was trying to mess around with the Pygame
module, and I used pygame.mixer
and pygame.key
. However, when I run the following block of code, it generates an error.
Code:
import pygame, sys
pygame.mixer.init()
# Assume the sound files exist and are found
kick = pygame.mixer.Sound("kick.wav")
clap = pygame.mixer.Sound("clap.wav")
while True:
keyPressed = pygame.key.get_pressed()
if keyPressed[pygame.K_a]:
pygame.mixer.Sound.play(kick)
if keyPressed[pygame.K_d]:
pygame.mixer.Sound.play(clap)
Error message:
*** error for object 0x101008fd0: pointer being freed was not allocated
Any help would be great!