Digging in a few places[1 
<http://gamedev.stackexchange.com/questions/1589/when-should-i-use-a-fixed-or-variable-time-step>
][2 <http://www.koonsolo.com/news/dewitters-gameloop/>][3 
<https://pythonhosted.org/pyglet/programming_guide/dispatching_events_manually.html>],
 
one potential solution could be to use your own event loop. Here's an 
example borrowing from dewitters that with a little tweaking might help:

import pyglet
from pyglet.window import key


class example(pyglet.window.Window):
    def __init__(self):
        super(example, self).__init__(640, 480, resizable=False, fullscreen=
False, caption="Test")
        self.clear()

        self.box = pyglet.image.load('sprite.png').get_texture()
        self.x = 0
        self.y = 0

        self.max_fps = 5
        self.fps = 25
        self.skip_ticks = 1000 / self.fps

        self.interpolation = 0.0

        self.GetTickCount = pyglet.clock.tick()
        self.next_game_tick = self.GetTickCount
        self.fps_display = pyglet.clock.ClockDisplay()


    def update(self):
        while not self.has_exit:
            dt = pyglet.clock.tick()
            self.GetTickCount += dt

            loops = 0
            while (self.GetTickCount > self.next_game_tick and loops < self.
max_fps):
                #update stuff
                self.next_game_tick += self.skip_ticks
                loops += 1

            self.interpolation = float(self.GetTickCount + self.skip_ticks - 
self.next_game_tick) / float(self.skip_ticks)

            self.draw()

            self.dispatch_events()

 
    def draw(self):
        self.clear()
        self.box.blit(self.x,self.y)
        self.fps_display.draw()

        self.flip()
      
    def on_key_press(self,symbol,modifiers):
        if symbol == key.ESCAPE:
            self.close()

if __name__ == '__main__':
    window = example()
    window.update()


-- 
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.

Reply via email to