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

Re: [pygame] One key press many events



Thanks for the tip!

czw., 17 wrz 2020 o 14:16 Daniel Foerster <pydsigner@xxxxxxxxx> napisał(a):
Jan:

Your player moves just once because you are listening for KEYDOWN events to move. KEYDOWN is only triggered when you first press a key. You can get the behavior you want in two ways.

Option 1: use pygame.key.get_pressed() to see the current state of the keys you want to check instead of examining events from the event queue. 

Option 2: have the UserInterface remember what KEYDOWNs have occurred and clear them when a KEYUP occurs.

— Daniel