[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Re: Pygame not handling keyboard tracking correctly



Im curious why "is" is bad in this case, as well. It's a constant; isn't that a good use for is, whether it's referring to an int or not? I tend to do this for event handling. Maybe ints are always pointers in python?

The caveat for events is just warning you that the queue could fill up if you didnt call pygame.event.get() at all.

On Jun 23, 2014 2:16 AM, "diliup gabadamudalige" <diliupg@xxxxxxxxx> wrote:
I called event.clear() cause it says in the Pygame documentation that if you leave unused events on the buffer that eventually it may fill up and cause the program to crash.

Also can you explain whyÂ

if x is True:Â
is not correct
and

if x == True
is correct?


On Mon, Jun 23, 2014 at 11:34 AM, Greg Ewing <greg.ewing@xxxxxxxxxxxxxxxx> wrote:
diliup gabadamudalige wrote:
pygame.event.clear()
before exiting the function

somehow when I removed that line the error stopped.

That would definitely be it! You were throwing away any
events that came in between calling event.get() and
reaching the end of your function. Not a good idea when
you rely critically on seeing *all* key up events.

I don't know why you thought you needed to call
event.clear(), but whatever your reason was, it was
probably wrong.


So may be I had to keep all the unused events for the next time the loop was entered. Is that correct?

Exactly correct.

--
Greg



--
Diliup Gabadamudalige

http://www.diliupg.com
http://soft.diliupg.com/

**********************************************************************************************
This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions.
**********************************************************************************************