Issue 466 in pyglet: Clock.tick() always scheduling events in the past.

6 views
Skip to first unread message

codesite...@google.com

unread,
Feb 5, 2010, 7:32:57 AM2/5/10
to pyglet...@googlegroups.com
Status: New
Owner: ----

New issue 466 by reddooots: Clock.tick() always scheduling events in the
past.
http://code.google.com/p/pyglet/issues/detail?id=466

Unless I'm missing something line 308 (in version 1.1.4) in clock.py will
always schedule an event in the past.

Current line:
item.next_ts = item.last_ts + item.interval

It should either be:
item.next_ts += item.interval
or
item.next_ts = ts + item.interval

On my computer the first option allows me to move an image across the
screen smoothly where as the second option always makes for jerky movement.

An example to make it clearer.
Lets say an event wants to run at 25 fps, it would start with:
last_ts = 0.000
next_ts = 0.040
interval = 0.040

When Clock.tick() gets around to calling the event (before the check to see
if next_ts is in the past) you end up with.
ts >= 0.040
next_ts = 0.000 + 0.040
last_ts = ts

So next_ts is now in the past.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

Reply all
Reply to author
Forward
0 new messages