1
votes

this is the code:

 pygame.mouse.get_pressed() 
    for event in pygame.event.get():
            if (event.type==pygame.KEYDOWN):
                if (event.key==pygame.K_LEFT):
                        mouth_x-=55
                if (event.key==pygame.K_RIGHT):
                        mouth_x+=55
                if event.type==MOUSEBUTTONDOWN:
                       pygame.quit()

When I press the mouse during the programme, nothing happens, but if I attach pygame.quit() to one of the key events it works. any ideas guys?

1

1 Answers

3
votes

You are testing for the mouse press inside the key pressed code

 pygame.mouse.get_pressed() 
    for event in pygame.event.get():
            if (event.type==pygame.KEYDOWN):
                if (event.key==pygame.K_LEFT):
                        mouth_x-=55
                if (event.key==pygame.K_RIGHT):
                        mouth_x+=55
            if (event.type==MOUSEBUTTONDOWN):
                pygame.quit()

That should work