本文整理汇总了Python中pyglet.clock.schedule_interval函数的典型用法代码示例。如果您正苦于以下问题:Python schedule_interval函数的具体用法?Python schedule_interval怎么用?Python schedule_interval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了schedule_interval函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_view
def test_view():
global map_width
map_ = Map(values.map_width, values.map_height)
for i in range(values.banks):
map_.add(EnergyBank(map_, random()))
for i in range(values.bodies):
map_.add(Body(map_, random()))
def update(dt):
map_.tick()
sim = Window(map_.width, map_.height)
sim_view = SimView(map_)
schedule_interval(update, 0.1)
@sim.event
def on_draw():
glClearColor(.5, .6, .6, 1)
sim.clear()
sim_view.draw()
graph = Window(500, 100)
graph_view = GraphView(map_)
@graph.event
def on_draw():
graph.clear()
graph_view.draw()
app.run()
示例2: add_transition
def add_transition(self, previous, next):
self.queue.append({
"previous": previous,
"next": next,
"phase": 1.,
})
clock.schedule_interval(self.tick, 1.0 / 30)
示例3: visible
def visible(self, visible):
self._visible = visible
clock.unschedule(self._blink)
if visible and self._active and self.PERIOD:
clock.schedule_interval(self._blink, self.PERIOD)
self._blink_visible = False # flipped immediately by next blink
self._blink(0)
示例4: _schedule_interval_callback
def _schedule_interval_callback(dt, func, interval, *args, **kwargs):
"""
Schedule a callback with specified interval.
Parameters
----------
dt: float
The number of seconds since the last function call.
func:function
The function to call when the timer lapses.
interval: float
The number of seconds to wait between each call
Example
-------
_schedule_interval_callback(dt, function, 1.0)
The function will be called one second after it
was last called.
"""
# schedule it
if interval > 0:
clock.schedule_interval(func, interval, *args, **kwargs)
# call it
func(dt, *args, **kwargs)
示例5: __init__
def __init__(self,size,color):
self.zulus=[]
self.ruleset=[]
self.size=size
self.color=color
# schedule the update function, 60 times per second
clock.schedule_interval(self.update, 1.0/120.0)
示例6: __init__
def __init__(self, *args, **kwargs):
self._items=set()
if args:
self._items.update(args)
else:
self._items.add(dummy)
for i in kwargs:
setattr(self,i,kwargs[i])
if not hasattr (self,'ruletype'):
self.ruletype='persistent'
# default ruletype
if self.ruletype == 'persistent':
_persistent.add(weakref.ref(self))
# periodic rules, of course rule must have a 'period' attribute
elif self.ruletype == 'periodic':
_periodic.add(weakref.ref(self)) # is this necessary ?
schedule_interval(self,self.period) # or schedule a oneshot rule ?
# will run only once, then erased from list
elif self.ruletype == 'oneshot':
_oneshot.add(weakref.ref(self))
# of course rule must have a 'condition' attribute
elif self.ruletype == 'conditional':
_conditional.add(weakref.ref(self))
else:
print ':: unrecognized type of rule'
self.setup()
print "::"
print ":: new rule :::::::::::::::::::::::::::::::::::::::::::::::::::"
print "::"
dumpObj(self)
示例7: __init__
def __init__(self):
pyglet.window.Window.__init__(self,vsync = True,fullscreen=True)
self.set_mouse_visible(False)
self.bgcolor=bgcolor
self.size_x,self.size_y=self.get_display_size()
self.center= self.size_x*0.5,self.size_y*0.5
self.paused=False
self.camera=Camera((self.center), 0.1)
self.key_actions = {
key.ESCAPE: lambda: exit(),
key.PAGEUP: lambda: self.camera.zoom(2),
key.PAGEDOWN: lambda: self.camera.zoom(0.5),
key.LEFT: lambda: self.camera.pan(self.camera.scale, -1.5708),
key.RIGHT: lambda: self.camera.pan(self.camera.scale, 1.5708),
key.DOWN: lambda: self.camera.pan(self.camera.scale, 3.1416),
key.UP: lambda: self.camera.pan(self.camera.scale, 0),
key.COMMA: lambda: self.camera.tilt(-1),
key.PERIOD: lambda: self.camera.tilt(+1),
key.P : lambda: self.toggle_pause(),
}
self.gl_setup()
# schedule the update function at 'fps' times per second
clock.schedule_interval(self.update, 1.0/100.0)
clock.set_fps_limit(max_fps)
示例8: __init__
def __init__(self, *args, **kwargs):
super(MainWindow, self).__init__(*args, **kwargs)
self.keys = window.key.KeyStateHandler()
self.push_handlers(self.keys)
# self.set_exclusive_mouse()
self.width, self.height, self.rat3d, self.ratex = 640, 480, 1.05, 0.5
self.zoom, self.expand, self.mapping, self.blend = 0, 0, 0, 1
self.fgc, self.bgc = (1.0, 1.0, 1.0, 0.9), (0.1, 0.1, 0.1, 0.1)
self.loadfgc, self.loadbgc = (0.4, 0.2, 0.4, 0.3), (0.6, 0.3, 0.6, 0.9)
self.instfgc, self.instbgc = (0.1, 0.1, 0.5, 0.9), (0.5, 0.9, 0.9, 0.8)
self.instbkwidth, self.instbkheight = 480, 400
bmplen = (self.instbkwidth / 8) * self.instbkheight
self.instbkbmp = (ctypes.c_ubyte * bmplen)(*([255] * bmplen))
self.ticktimer, self.tick, self.insttimer, self.inst = 0.5, 0.0, 30, 1
self.printing, self.solver = 1, deque()
self.stat = [None, 0, Queue.Queue(512)] # (key(1-9), direc), count, queue
self.cmax, self.tanim = 18, [6, 3, 1, 3] # frames in rotate moving, speeds
self.tcos, self.tsin = [1.0] * (self.cmax + 1), [0.0] * (self.cmax + 1)
for i in xrange(1, self.cmax):
t = i * math.pi / (2.0 * self.cmax) # 0 < t < pi/2
self.tcos[i], self.tsin[i] = math.cos(t), math.sin(t)
self.tcos[self.cmax], self.tsin[self.cmax] = 0.0, 1.0 # pi/2 regulation
self.InitRot()
self.InitAxis()
self.InitGL(self.width, self.height)
self.textures = [None] * (len(self.ary_norm) * 2 + 1 + len(TEXIMG_CHAR))
self.loading, self.dat = 0, [('', 0, 0)] * len(self.textures)
resource.add_font(FONT_FILE)
self.font = font.load(FONT_FACE, 20)
self.fontcolor = (0.5, 0.8, 0.5, 0.9)
self.fps_display = clock.ClockDisplay(font=self.font, color=self.fontcolor)
self.fps_pos = (-60.0, 30.0, -60.0)
clock.set_fps_limit(60)
clock.schedule_interval(self.update, 1.0 / 60.0)
示例9: __init__
def __init__(self):
super(HelloWorld, self).__init__()
# a cocos.text.Label is a wrapper of pyglet.text.Label
# with the benefit of being a cocosnode
self.left = cocos.sprite.Sprite('foot.png', (300, 100))
self.right = cocos.sprite.Sprite('footr.png', (375, 100))
self.add(self.left)
self.add(self.right)
self.steps = cycle([
random.choice([
self.hop_left,
self.hop_right,
self.wait,
self.step_left,
self.step_right,
self.wiggle,
self.reset,
self.reset,
]) for _ in range(7)] + [self.reset]
)
clock.schedule_interval(self.next_step, 0.5)
示例10: __init__
def __init__(self, *args, **kwargs):
#Let all of the arguments pass through
self.win = window.Window.__init__(self, *args, **kwargs)
self.maxaliens = 50 # max num of aliens simultaneously on the screen
clock.schedule_interval(self.create_alien, 0.5)
clock.schedule_interval(self.update, 1.0/30) # update at FPS of Hz
#clock.set_fps_limit(30)
# setting text objects
ft = font.load('Tahoma', 20) #Create a font for our FPS clock
self.fpstext = font.Text(ft, y=10) # object to display the FPS
self.score = font.Text(ft, x=self.width, y=self.height,
halign=pyglet.font.Text.RIGHT,
valign=pyglet.font.Text.TOP)
# reading and saving images
self.spaceship_image = pyglet.image.load('images/ship3.png')
self.alien_image = pyglet.image.load('images/invader.png')
self.bullet_image = pyglet.image.load('images/bullet_white_16.png')
# create one spaceship
self.spaceship = Spaceship(self.spaceship_image, x=50, y=50)
self.aliens=[] # list of Alien objects
self.bullets=[] # list of Bullet objects
示例11: __init__
def __init__(self, *args, **kwargs):
self._id = chr((Agent.new_id()%26)+97) # converts int to letters
self._items=set()
if args:
self._items.update(args)
else:
self._items.add(dummy)
for i in kwargs:
setattr(self,i,kwargs[i])
if not hasattr (self,'agenttype'):
self.agenttype='persistent'
# default agenttype
if self.agenttype == 'persistent':
_persistent.add(self)
# periodic agents, of course agent must have a 'period' attribute
elif self.agenttype == 'periodic':
_periodic.add(self) # is this necessary ?
schedule_interval(self.tick,self.period) # or schedule a oneshot agent ?
# will run only once, then erased from list
elif self.agenttype == 'oneshot':
_oneshot.add(self)
# of course agent must have a 'condition' attribute
elif self.agenttype == 'conditional':
_conditional.add(self)
else:
print ':: unrecognized type of agent'
self.setup()
print "::"
print ":: new agent :::::::::::::::::::::::::::::::::::::::::::::::::::"
print "::"
dumpObj(self)
示例12: animate
def animate():
VIEW.set_fullscreen(True)
# normal loop : run the preview at good rate
# clock.schedule_interval(paint, FRAMERATE)
# and try (soft) to run anim at same speed
clock.schedule_interval(tick, FRAMERATE)
pyglet.app.run()
示例13: __init__
def __init__(self, *k, **d):
super(Window, self).__init__(*k, **d)
self.img = pyglet.resource.image('undo.png')
self._enable_alpha()
self._load_cursors()
clock.schedule_interval(self.update, 1/60.0)
self.logo = Logo()
示例14: start
def start(self):
if self.__running:
unschedule(self.update)
self.__running = False
else:
schedule_interval(self.update, self.speed)
self.__running = True
示例15: main
def main():
# schedule pyglet loop at max framerate
# and the tick function at more than fps
# frame / time driven loop
options = {
'DEBUG': 1,
'PREVIEW_SIZE': (800, 600),
'BGCOLOR': (0.95, 0.95, 0.95, 0), # background
'FPS': 60, # display max framerate
'PicPS': 25, # images per second for movie export
'MODE': 'PREVIEW', # options are: 'FULL'; 'PREVIEW'; 'EXPORT'
'DURATION' : 3,
'SCENE_FOLDER' : 'scene',
}
engine = Engine(**options)
#---run loop options-------------------------------------------------------
if engine.MODE in ('FULL','PREVIEW'):
clock.schedule_interval(engine.frame_paint,1.0/engine.FPS)
clock.schedule_interval_soft(engine.tick, 1.0/(1.0*engine.FPS))
elif engine.MODE == 'EXPORT': # export loop
# try (soft) to run export method at final anim speed,
clock.schedule_interval_soft(engine.export_loop,1.0/engine.PicPS)
# while (soft) run the preview at good rate
#clock.schedule_interval_soft(self.frame_, 1.0/self.FPS,scene)
pyglet.app.run()