After these changes, all your `break` statements are no longer needed.
First things I noticed, you are only parsing one event per game loop. You're missing a ton of events. Instead use:
for event in pygame.event.get():For `eat_cpu`, instead sleeping. Use either `time.wait` or `time.delay` depending on your requirement. Sleep doesn't use your CPU to delay. And `eat_cpu` has a undefined time.Your main loop becomes:
while Working:
for event in pygame.event.get():
# handle events
# math
# render
`get_key_info(k)` becomes:
def get_key_info(k):
return pygame.key.name(k)On Tue, May 12, 2015 at 7:42 PM, Виталий <vitalik1231@xxxxxxxxx> wrote:Hi, I got bug in pygame
If I change window resolution in keyboard handler then I got strange KEYUP event:
<Event(2-KeyDown {'scancode': 114, 'key': 275, 'unicode': u'', 'mod': 0})> (K_RIGHT)
<Event(3-KeyUp {'scancode': 0, 'key': 275, 'mod': 0})> (K_RIGHT) # HERE
<Event(3-KeyUp {'scancode': 114, 'key': 275, 'mod': 0})> (K_RIGHT)
but if I hit key very quickly, then I got that:
<Event(2-KeyDown {'scancode': 114, 'key': 275, 'unicode': u'', 'mod': 0})> (K_RIGHT)
<Event(3-KeyUp {'scancode': 0, 'key': 275, 'mod': 0})> (K_RIGHT)
And sometimes pygame stops to receive any keyboard events, but mouse and all other is ok (ALT + F4 still works)
To check bug try to press "a", "s", "d", "right" at the same time few times, after few tries pygame stops to receive any keyboard events.
My system:
$ uname -a
Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.57-3 x86_64 GNU/Linux
$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"
$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, pygame
>>> sys.version
'2.7.3 (default, Mar 13 2014, 11:03:55) \n[GCC 4.7.2]'
>>> pygame.ver
'1.9.1release'
--Jake