thealphadollar / brkout

A game made using PyGame under CodeClub as a learning project.
MIT License
8 stars 19 forks source link

Bug: Game crashes when no joystick is conncected #56

Closed steve050798 closed 5 years ago

steve050798 commented 5 years ago

When starting a game with only a keyboard connected (no joystick)

This error is thrown: screenshot from 2018-12-16 19-13-58

Identified the issue is caused because pygame.joystick.get_count() [in gameloop(striker_color)] returns zero and hence no joystick object is created. Hence the UnboundedLocalVariable Error.

Solution: joystick=None (in gameloop(striker_color)

and the following highlighted changes in event(joystick):

screenshot from 2018-12-18 09-13-03

Submitting a pull request with the suggested solution