def main(): global target, step while not w.has_exit: clock.tick() w.clear() target.pos.x += step if abs(target.pos.x) >= 17: step *= -1 w.dispatch_events() context.render() w.flip()
def update(dt): global target, step #clock.tick() w.clear() target.pos.x += step if abs(target.pos.x) >= 17: step *= -1 #w.dispatch_events() context.render() w.flip() if w.has_exit: from pyglet import app app.event_loop.exit()
context.osd.add_object(pyglet.clock.ClockDisplay()) context.control = miru.input.SimpleMouseControl() context.camera.lights = miru.camera.LightGroup([ miru.camera.DirectionalLight()]) context.camera.pos.z = 5 context.camera.angle.x = -15 batch = pyglet.graphics.Batch() group = miru.graphics.ColorGroup(0.2) torus = geom.Torus(divisions=75) #torus.get_vlist(batch, group) vlist = geom.get_vlist(torus, batch, group) torus_obj = miru.core.Object(batch) torus_obj.angle.z = 15 context.add_object(torus_obj) v = 35 def update(dt): dy = dt * v torus_obj.angle.x += dy pyglet.clock.schedule_interval(update, 1/60.) while not window.has_exit: window.clear() pyglet.clock.tick() window.dispatch_events() context.render() window.flip()
def on_draw(): window.clear() context.render()