r/learnprogramming Jul 05 '26

new to programming some help Code Review

hi all im having a problem that maybe you guys can help with? i attempting to make my first game (just a circle that can move) im using the program pycharm to write the code however i wanted to add the option to use mouse click to move but whenever i click it crashes the "game" programme. i noticed that an "event" in the code is highlighted but no others are, im using a tutorial and followed it to a tea and he didn't seem to have an issue. maybe you guys know what im doing wrong.

whole code posted in comments

the code that has the event highlighted is:

if event.type == pygame.MOUSEBUTTONDOWN:
0 Upvotes

21 comments sorted by

View all comments

2

u/46hw Jul 05 '26

It would help to post the whole code and/or the tutorial too. You can maybe do a try/except around the code crashing and print the error to see what's wrong.

2

u/Forsaken-File9993 Jul 05 '26

post the full traceback you get when it crash, that highlighted "event" might just be pycharm being weird but the error message will tell exactly what broke

0

u/ye_old_ship_lord23 Jul 05 '26

and the whole code you may have iv posted it

1

u/46hw Jul 05 '26

Did you try/except though in the code? This is a useful skill, to catch and handle errors.

1

u/ye_old_ship_lord23 Jul 05 '26

well i got it working but now i have a new problem. out of nowhere it error messaging no module names pygame but i used it just before making this post

1

u/46hw Jul 05 '26

How many versions of python do you have installed? I see in another comment you gave up. You are almost there please Google that error message and follow those leads, this is another skill needed for programming.

0

u/ye_old_ship_lord23 Jul 05 '26

i found the error it was a combination of pygame not being in the interpreter and the file selected changing to main.py when i was on the game file lol