本文整理汇总了Python中pyglet.clock.schedule_interval函数的典型用法代码示例。如果您正苦于以下问题:Python schedule_interval函数的具体用法?Python schedule_interval怎么用?Python schedule_interval使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了schedule_interval函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:evuez,项目名称:mutations,代码行数:33,代码来源:test.py
示例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)
开发者ID:Bogdanp,项目名称:ymage,代码行数:7,代码来源:transition.py
示例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)
开发者ID:bitcraft,项目名称:pyglet,代码行数:7,代码来源:caret.py
示例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)
开发者ID:mjgilles,项目名称:smile,代码行数:26,代码来源:state.py
示例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)
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:zululand.py
示例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)
开发者ID:msarch,项目名称:py,代码行数:30,代码来源:rules.py
示例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)
开发者ID:msarch,项目名称:py,代码行数:26,代码来源:pygland.py
示例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)
开发者ID:HatsuneMiku,项目名称:HatsuneMiku,代码行数:34,代码来源:rcube.py
示例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)
开发者ID:damilare,项目名称:dojoism,代码行数:25,代码来源:dance.py
示例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
开发者ID:guillermoaguilar,项目名称:pyglet_tutorial,代码行数:29,代码来源:game.py
示例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)
开发者ID:msarch,项目名称:py,代码行数:31,代码来源:agent.py
示例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()
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:engine.py
示例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()
开发者ID:hugoruscitti,项目名称:examplelab,代码行数:7,代码来源:drag_and_drop.py
示例14: start
def start(self):
if self.__running:
unschedule(self.update)
self.__running = False
else:
schedule_interval(self.update, self.speed)
self.__running = True
开发者ID:eordano,项目名称:random,代码行数:7,代码来源:conway.py
示例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()
开发者ID:msarch,项目名称:py,代码行数:28,代码来源:engine.py
示例16: animate
def animate(field):
e = Engine(field,fullscreen=True)
# normal loop : run the preview at good rate
clock.schedule_interval(e.paint_a_frame, FRAMERATE)
# and try (soft) to run anim at same speed
clock.schedule_interval_soft(e.tick, FRAMERATE)
pyglet.app.run()
开发者ID:msarch,项目名称:py,代码行数:7,代码来源:animate.py
示例17: __init__
def __init__(self, *args, **kwargs):
#Let all of the arguments pass through
self.win = window.Window.__init__(self, *args, **kwargs)
clock.schedule_interval(self.update, 1.0/30) # update at 30 Hz
clock.schedule_interval(self.create_alien, 1.0/2) # update at 5 Hz
# 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)
# loading image
self.spaceship_image = pyglet.image.load('images/ship3.png')
self.spaceship = Spaceship(self.spaceship_image, x=200, y=50)
self.alien_image = pyglet.image.load('images/invader.png')
self.aliens = []
self.bullet_image = pyglet.image.load('images/bullet_white_16.png')
self.bullets = []
开发者ID:ocarneiro,项目名称:pyglet_tutorial,代码行数:26,代码来源:game5.py
示例18: scene1
def scene1():
print "scene1"
s.Narration('Sending me into the snow-storm')
s.Narration('Without any help')
s.Narration('Again')
s.Narration('Alone')
clock.schedule_interval(spawn_troll, 5)
clock.schedule_once(scene2, 20)
开发者ID:dragonfi,项目名称:ld25-you-are-the-hero,代码行数:8,代码来源:script.py
示例19: __init__
def __init__(self, difficulties, camera):
self.difficulties = difficulties
self.counter = 0
self.labels = deque()
self.credit_it = self.credit_text()
self.camera = camera
schedule_interval(self.update_position, 0.017)
schedule_once(self.update_text, 0)
开发者ID:jribbens,项目名称:wasabi-root,代码行数:8,代码来源:credits.py
示例20: village_scene
def village_scene(dt):
clock.unschedule(spawn_troll)
s.Narration("This time")
s.Narration("They will say")
s.Title("You are the Villain")
clock.schedule_interval(village_callback, 5)
for i in range(counter + 4):
s.Villager(on_death = decrement_counter)
开发者ID:dragonfi,项目名称:ld25-you-are-the-hero,代码行数:8,代码来源:script.py
注:本文中的pyglet.clock.schedule_interval函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论