How to use the pyglet.clock function in pyglet

To help you get started, weā€™ve selected a few pyglet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Zumorica / pyDLASYIAS / pyDLASYIAS / scenes.py View on Github external
def on_exit(self):
        super().on_exit()
        self.isActive = False
        self.enable_handlers(False)
        director.window.remove_handlers(self)
        pyglet.clock.unschedule(self.update)
github lordmauve / lepton / examples / logo.py View on Github external
for i in range(12000):
	group.new(template, position=positions.pop(), age=49.35)

win.set_visible(True)
pyglet.clock.schedule_interval(default_system.update, (1.0/40.0))
pyglet.clock.set_fps_limit(None)

label = pyglet.text.Label("Lepton", font_name="Helvetica", font_size=72, bold=True,
	color=(0,0,0,0), anchor_x="center", x=0, y=-200)

def fade_in_label(dt):
	global label
	alpha = label.color[-1] + 2
	label.color = label.color[:-1] + (min(alpha, 255),)
	pyglet.clock.schedule_once(fade_in_label, 1.0/40.0)
pyglet.clock.schedule_once(fade_in_label, 6)

t = 90
d = -80
approach = 0.6
rot = 1.0


@win.event
def on_draw():
	global t, d, approach, rot
	win.clear()
	glLoadIdentity()
	glTranslatef(0, 0, -950)
	label.draw()
	glLoadIdentity()
	t += rot
github adamlwgriffiths / PyGLy / pygly / pyglet_monkey_patch.py View on Github external
def idle( self ):
        pyglet.clock.tick( poll = True )
        # don't call on_draw
        return pyglet.clock.get_sleep_time( sleep_idle = True )
github Permafacture / data-oriented-pyglet / examples / second.py View on Github external
vert_dtype = dtype_tuple(np.float32,gl.GL_FLOAT)
color_dtype = dtype_tuple(np.float32,gl.GL_FLOAT)

#Limit run time for profiling
run_for = 15 #seconds to run test for
def done_yet(duration = run_for, start=time.time()):
  return time.time()-start > duration


#Set up window
width, height = 640,480
window = pyglet.window.Window(width, height,vsync=False)
#window = pyglet.window.Window(fullscreen=True,vsync=False)
#width = window.width
#height = window.height 
fps_display = pyglet.clock.ClockDisplay()
text = """Optimized DOP"""
label = pyglet.text.HTMLLabel(text, x=10, y=height-10)


def draw(verts,colors):
    '''draw the numpy arrays `verts` and `colors`.'''

    gl.glClearColor(0.2, 0.4, 0.5, 1.0)
    gl.glBlendFunc (gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)                             
    gl.glEnable (gl.GL_BLEND)                                                            
    gl.glEnable (gl.GL_LINE_SMOOTH);                                                     
    gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
    gl.glEnableClientState(gl.GL_COLOR_ARRAY)

    gl.glVertexPointer(2, vert_dtype.gl_type, 0, verts.ctypes.data)
    gl.glColorPointer(3,  color_dtype.gl_type, 0, colors.ctypes.data)
github vispy / vispy / vispy / app / backends / _pyglet.py View on Github external
def _vispy_process_events(self):
        # pyglet.app.platform_event_loop.step(0.0)
        pyglet.clock.tick()
        for window in pyglet.app.windows:
            window.switch_to()
            window.dispatch_events()
            window.dispatch_event('on_draw')
github pyglet / pyglet / contrib / currently-broken / layout / examples / xhtml_replaced.py View on Github external
@select('cube')
def on_mouse_press(element, x, y, button, modifiers):
    global rate
    rate = -rate
layout.push_handlers(on_mouse_press)

glClearColor(1, 1, 1, 1)

window.set_visible()

rate = 50

while not window.has_exit:
    dt = clock.tick()
    CubeDrawable.angle += dt * rate
    print 'FPS = %.2f\r' % clock.get_fps(),

    window.dispatch_events()
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()

    layout.draw()
    window.flip()
github pyglet / pyglet / contrib / currently-broken / spryte / cars.py View on Github external
win = window.Window(vsync=False)
fps = clock.ClockDisplay(color=(1, 1, 1, 1))

cars = spryte.SpriteBatch()
car = resource.image('car.png')
car.anchor_x = 16
car.anchor_y = 20
for i in range(NUM_CARS):
    s = spryte.Sprite(car,
        win.width*random.random(), win.height*random.random(),
        batch=cars, dr=-45 + random.random()*90)

while not win.has_exit:
    win.dispatch_events()
    clock.tick()

    win.clear()
    for car in cars:
        car.rotation = (car.rotation + car.dr) % 360
    cars.draw()
    fps.draw()
    win.flip()
github hansonrobotics / HEAD / src / tts / src / tts / SoundFile.py View on Github external
def __init__(self):
        #Fix to get the pyglet in background thread exit gracefully on keyboard
        #interrupt (CTRL+C)
        pyglet.clock._get_sleep_time = pyglet.clock.get_sleep_time
        pyglet.clock.get_sleep_time = lambda sleep_idle: pyglet.clock._get_sleep_time(False)

        threading.Timer(0.2, pyglet.app.run).start()
        rospy.on_shutdown(pyglet.app.exit)
        self.gletplayer = pyglet.media.Player()
github CommonAnts / OIASG / oiasg / lib / game.py View on Github external
def _end(self):
		pyglet.clock.unschedule(self.play_round)
		self.__dict__.clear()
GamePlay.register_event_type('on_update')
github pyglet / pyglet / pyglet / media / player.py View on Github external
self.pause()
        if not self.source:
            return

        if bl.logger is not None:
            bl.logger.log("p.P.sk", time)

        self._mclock.set_time(time)
        self.source.seek(time)
        if self._audio_player:
            # XXX: According to docstring in AbstractAudioPlayer this cannot
            # be called when the player is not stopped
            self._audio_player.clear()
        if self.source.video_format:
            self.update_texture()
            pyglet.clock.unschedule(self.update_texture)
        self._set_playing(playing)