[SDL] Movement bug
Donny Viszneki
smirk at thebuicksix.com
Thu Aug 4 10:07:04 PDT 2005
Yeah, did you even read the guy's email?
On Aug 2, 2005, at 10:36 AM, Josh Matthews wrote:
> The easiest way to get around this is call
> SDL_EnableKeyRepeat(0.5,0.5); before getting into your movement code
> (you only need to call it once), this will generate SDL_KEYDOWN events
> whenever a key is held down as well.
On Aug 3, 2005, at 9:58 AM, Jesper Liljegren wrote:
> The problem is when i press and _hold_ Q I move left, then I press E
> and _hold_, this makes me move right.
> All good so far. BUT, when i relese E (and still holding Q), I want to
> start moving left, but I don't!
> The sprite just stops :(
Jesper, the reason holding is working, but pressing once is not, is
because of so-called key-repeat. Just as when you type into your email
client or word processor. Pressing Q once is only triggering your event
handler for the letter Q one time. After holding Q, your system is
sending a string of Qs to your program, and your Q event handler is
being triggered many times, resulting in more substantial motion.
If you don't understand why releasing the E key is not returning you
back to Q movement, simply open up your word processor or start
composing a new email message. Press and hold Q for a few seconds and
watch the list of Qs grow. Continue holding Q while you press and hold
E for a few seconds, and watch the list of Es grow. Now release E, and
you will notice that you're not getting any more Qs.
All in all, Torsten's advice is sound. However, now I hope you
understand the underlying cause of your problems.
More information about the SDL
mailing list