set_repeat isn't exactly ideal because it produces jerky movement. I just ignore the events altogether and use pygame.key.get_pressed once a tick.
-FM On Fri, Oct 31, 2008 at 11:47 AM, Paul Pigg <[EMAIL PROTECTED]> wrote: > Have you tried using the pygame.key.set_repeat() function? Otherwise, I > would use the KEYDOWN event to set the speed in either x or y direction (I > like diagonal movement ;)) and the KEYUP event to reset the directional > speed to zero. With that method, you'd need logic to deal with abrupt > changes such as the user holding the up arrow, then pressing the down arrow > before releasing the up arrow (which may again be taken care of by > set_repeat). > > --p > > On Fri, Oct 31, 2008 at 3:13 AM, Michael Fiano <[EMAIL PROTECTED]> > wrote: >> >> On Fri, 31 Oct 2008 18:39:31 +1000 >> Nicholas Dudfield <[EMAIL PROTECTED]> wrote: >> >> > I am pretty sure you don't need to run event.pump() for every event. >> > >> > It doesn't seem like `keyinput` is being used at all so it's probably >> > not needed. >> >> You're right. I don't need it anymore. keyinput was being used before >> to make it so that more than one key could be pressed to move the >> character. I gave up due to minor bugs in my code and forgot to remove >> that little bit. What I would like to do: >> >> Right now if you are holding a directional key to move, and you press a >> different directional key at the same time, the player will stop, >> instead of changing directions. If anyone could give me some pointers >> on how to do this I'd be very happy, because I want it to be >> gamepad-friendly too. >> >> > <code> >> > elif event.key == K_UP or event.key == K_DOWN or event.key == K_LEFT >> > or event.key == K_RIGHT: >> > do_stuff() >> > </code >> > >> > The python idiom for this is >> > >> > <code> >> > elif event.key in (K_UP, K_DOWN, K_LEFT, K_RIGHT): >> > do_stuff() >> > </code> >> >> Aha, nice. Thanks! > >