Hi, I would like to ask is it possible for pygame to respond on a key press immediately? I am trying to make a drumming simulation and the response comes after 1-2 seconds. The code is:
import pygame, sys
from pygame import *
pygame.mixer.init()
pygame.init()
#Loading sounds...
snare = pygame.mixer.Sound('Snare.wav')
hihat = pygame.mixer.Sound('HiHat.wav')
kick = pygame.mixer.Sound('Kick.wav')
crash = pygame.mixer.Sound('Crash.wav')
tom1 = pygame.mixer.Sound('HiTom.wav')
tom2 = pygame.mixer.Sound('LowTom.wav')
tomFloor = pygame.mixer.Sound('FloorTom.wav')
ride = pygame.mixer.Sound('Ride.wav')
hihatOpen = pygame.mixer.Sound('HiHatOpen.wav')
screen = pygame.display.set_mode((640,320), 0, 32)
pygame.display.set_caption('PyDrummer')
background = pygame.image.load('BG.jpg').convert()
while 1:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
if event.key == K_b:
kick.play()
#... and so on i check if a key is pressed, and if it is, i play sound
#...
screen.blit(background, (0,0))
pygame.display.flip()
can anybode help me?