I got sounds that I play from a list called sounds
. It plays a sound, store the time when the sound is played in start
, waits 6 seconds and plays the next sound from the list. Now I want to capture a reaction time between these 6 seconds with a keydown. If the condition is true then I click the button and it captures the time and store it in end
. Then, the difference between end
and start
should give me the result. The problem is, that it does not measure the time right. It always gives me millisconds, even if I way longer bfore I click. I wonder what I am doing wrong here?
start = time.time()
for i in range(len(arr)):
pygame.mixer.music.load(sounds[i])
pygame.mixer.music.play()
for e in pygame.event.get():
if e.type == pygame.KEYDOWN:
if e.key == pygame.K_RIGHT:
if condition:
end = time.time()
diff = end - start
while pygame.mixer.music.get_busy():
time.sleep(6)