Don't forget to take into account dt when doing your movement as well.
You probably want to use it is a multiplier on your movement factor so
it moves the same number of pixels per second regardless of framerate!

On Wed, May 6, 2009 at 9:09 AM, Timothy McDowell <[email protected]> wrote:
> Thanks a lot. The best I was getting was jittery movement.
>
> On Tue, May 5, 2009 at 11:04 PM, Mike Rooney <[email protected]> wrote:
>>
>> On Tue, May 5, 2009 at 8:14 PM, Zonbi <[email protected]> wrote:
>> >
>> > I'd like to make a simple Pong clone. However, I can't seem to figure
>> > out how to see if a button keeps being held down.
>> >  Ie: Check to see if the button is stil being held, and if so, call
>> > the on_key event again, or be able to set up a 'while' loop (while
>> > button is pressed, do this...).
>> >
>>
>> I think what you want is to push a keyhandler then check for what is
>> pressed in your tick. Something like:
>>
>> keys = pyglet.window.key.KeyStateHandler()
>>
>> class MyWindow(pyglet.window.Window):
>>  def __init__(self):
>>    pyglet.window.Window.__init__(self)
>>    self.push_handlers(keys)
>>    pyglet.clock.schedule_interval(self.tock, 1/30.0)
>>  def tick(self, dt):
>>    if keys[pyglet.window.key.DOWN]: movedown()
>>    if keys[pyglet.window.key.UP]: moveup()
>>
>> I generally wouldn't recommend using an elif there because multiple
>> keys can of course be pressed at once and you generally don't want to
>> take the first one; they should logically cancel out.
>>
>>
>> --
>> Michael Rooney
>> [email protected]
>>
>>
>
>
>
> --
> --Brains.
>
> >
>



-- 
Michael Rooney
[email protected]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to