I haven't written much Python in a couple of months, and I didn't test
the code below at all except to check that it compiles, but it's a
start. Feel free to steal, tweak, and correct. If I have Python's
module behavior straight, you should be able to stick this in
gametime.py, import it, and then just call gametime.pause() and
gametime.unpause().

import pyglet.clock, time

pause_start = 0
total_pause_time = 0
paused = False

def game_time():
        if paused:
                return pause_start - total_pause_time
        else:
                return time.time() - total_pause_time

def pause():
        if not paused:
                paused = True
                pause_start = time.time()

def unpause():
        if paused:
                paused = False
                total_pause_time += time.time() - pause_start

pyglet.clock.get_default().time = game_time
--~--~---------~--~----~------------~-------~--~----~
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