Thanks for the response guys, I have it capped at vsync, but it's not
reliable enough, especially on slower machines or if there are slowdowns
due to many objects.
My main concern is making sure movement is deterministic, so things like
replays and speed checking are able to be calculated properly and reliably.
So for instance even if the simulation ran at 10 FPS, even if it's choppy
or a 'slideshow', things are triggering and happening at the correct points
in time. Maybe movement would be based on time rather than delta time. If
it's variable, this won't be possible if the game runs too fast or too slow
or drops frames. I hope this makes sense on what I'm trying to accomplish.
On Wednesday, November 2, 2016 at 2:52:15 PM UTC-5, Josh wrote:
>
> Smooth motion in pyglet should always take place inside an event loop
> specified by an interval scheduled function. On_draw will never fire in the
> middle of that loop unless you have code in the loop that tells it to.
> Since your loop function must accept a dt parameter, you can ensure your
> motion is correctly interpolated. For example:
>
> import pyglet
> window = pyglet.window.Window(800, 800)
> mypic = pyglet.resource.image('mypic.jpg')
> sprite = pyglet.sprite.Sprite(mypic, x=0, y=0, subpixel=True)
>
> def move_sprite(dt):
> sprite.x += 50*dt
>
> @window.event
> def on_draw():
> window.clear()
> sprite.draw()
>
> pyglet.clock.schedule_interval(move_sprite, 1.0/60)
>
> pyglet.app.run()
>
>
>
> In this code, on_draw() will be called every time pyglet's clock has
> completed move_sprite. If the interval isn't exactly one sixtieth of a
> second it doesn't matter, the clock will pass the dt of when it actually
> firs, not when it was scehduled.
>
>
> On Wednesday, October 26, 2016 at 2:19:47 PM UTC-5, Baitshop wrote:
>>
>> I was wondering if a fixed timestep is possible with pyglet's current
>> event loop? When using schedule_interval for 1/60.0 it's not always
>> consistent since it is using a variable time step.
>>
>> How is one supposed to separate the rendering from the updates
>> considering adjusting the position of the sprite will move it next time it
>> is drawn. I am also having trouble understanding how interpolation would
>> be configured using the pyglet app system as the on_draw does not get
>> passed any dt. I have tried an older implementation that I found, but it
>> seems like it fires the scheduled function faster than the dt actually is.
>> Would anyone happen to have a proper example of how a fixed time step would
>> work using a sprite and pyglet?
>>
>
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.