Closed Subisuresh321 closed 8 months ago
specific part of code where the trouble is:
# Check for matches
for i in range(min(len(lowercase_letters),len(uppercase_letters))):
if lowercase_letters[i] is not None:
for j in range(min(len(lowercase_letters),len(uppercase_letters))):
if i != j and uppercase_letters[j] is not None and lowercase_letters[i].get_rect(topleft=lowercase_positions[i]).colliderect(uppercase_letters[j].get_rect(topleft=uppercase_positions[j])):
# The letters do not match
wrong_sound.play()
screen.blit(wrong_image, (350, 250)) # Adjust the position as needed
pygame.display.flip() # Update the display to show the wrong image
pygame.time.wait(3000) # Wait for 1 seconds
if uppercase_letters is not None and lowercase_letters[i].get_rect(topleft=lowercase_positions[i]).colliderect(uppercase_letters[i].get_rect(topleft=uppercase_positions[i])):
# Display the correct image & sound
correct_sound.play()
screen.blit(correct_image, (350, 250)) # Adjust the position as needed
pygame.display.flip() # Update the display to show the correct image
pygame.time.wait(3000) # Wait for 1 seconds
# Remove the letters
lowercase_letters[i] = uppercase_letters[i] = None
pygame.display.flip()
try replacing pygame.time.wait(milliseconds)
by await asyncio.sleep(float(milliseconds)/1000)
the browser does not allow to pause wasm programs, so you must idle looping instead
thanks bro you are a life saver
in my code..there is image that shows correct when a match is found along with a sound which usually stays for 1 sec...but in browser it is going fast like a blink and i cant hear the sound's whole portion...only some beeps