Pygame: mouse buttons not working

I am trying to follow this tutorial: Creating a Mario Maker style game in Python - YouTube
at 1:33:47, he asks me to test the mouse which does not work. Can you please help me to solve it.

Repl link: https://replit.com/@JustinYeo/Pirate-Mario#menu.py

Thank You

Hi @JustinYeo

Thanks for your question.

I just forked your code and - long story short - it works fine. I think the issue here is:

  1. You are displaying the number 2 repeatedly for some reason that isn’t clear (I’m not watching the whole video). I commented this out:

image

  1. The code you have written isn’t doing anything, it is just pass for both buttons so I changed them to print statements:

image

Only using the middle mouse button or right mouse button will work when you click on the icons in the bottom right of the screen:

image

Hope this helps.

1 Like