-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix _get_pressed() returning list of booleans #18
base: master
Are you sure you want to change the base?
Conversation
Well done!
|
What activity did you notice this in? Any steps to reproduce? |
The issue was originally encountered in BallAndBrick activity. My testing environment consists of sugar 0.118 on Ubuntu 22.04 (Pygame 2.5.2, Python 3.10.12).
|
I tested the changes you made and it works just fine without this change to sugargame. |
Did you test all the commits? The changes made in b03de8c replaced the usage of pygame.key.get_pressed() and thus the BallAndBrick activity would work fine without any changes to sugargame. |
191eecb
to
04f295c
Compare
_get_pressed() returns a list of 134 booleans. Checking key presses for a key such as pygame.K_RIGHT(1073741903) would go past the 134 element list resulting in an IndexError. * return self.__keystate dict from _get_pressed() instead of it's values.
04f295c
to
c49f525
Compare
I wanted to change the commit message only but mistakenly pushed some unwanted changes. So had to force push twice. |
The changes commited in e4d3122 converted the type of self.__keystate from bool array into dict(int: bool). However, _get_pressed() still returns a list of 134 booleans. Checking key presses for a key such as pygame.K_RIGHT(1073741903) would go past the size of the list resulting in an IndexError.
Solves the issue encountered in sugarlabs/ball-and-brick-activity#24 (comment).
@quozl, @walterbender, @chimosky please review.