本文整理汇总了Python中pyglet.app.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的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: __init__
def __init__(self):
super(GameWindow, self).__init__()
clock.schedule_interval(self.on_update, 1.0 / 60)
self.quad_sprite = Quad(self, 1, 1, scale=3)
self.game_map = Map(self, 0, 0)
app.run()
开发者ID:jgumbley,项目名称:quad-game,代码行数:8,代码来源:game.py
示例3: run
def run(self):
"""Start the game.
"""
self.setup_pyglet()
self.setup_gl()
self.switch_handler(config.start_mode)
self.window.set_visible()
app.run()
开发者ID:italomaia,项目名称:turtle-linux,代码行数:9,代码来源:main.py
示例4: run
def run(self):
"""Start the game.
"""
self.setup_pyglet()
self.setup_gl()
self.switch_handler("menu")
self.window.set_visible()
app.run()
开发者ID:jseutter,项目名称:pyweek10,代码行数:9,代码来源:main.py
示例5: main
def main():
win = Window(fullscreen=True)
win.on_resize = on_resize
try:
try:
install_shaders('allGreen.frag', 'zoomRotate.vert')
except ShaderError, e:
print str(e)
return 2
win.on_draw = lambda: on_draw(win)
app.run()
开发者ID:adam-urbanczyk,项目名称:chemshapes,代码行数:13,代码来源:demo.py
示例6: main
def main():
win = Window(fullscreen=True, visible=False)
camera = Camera(win.width, win.height, (0, 0), 100)
renderer = Renderer()
maze = Maze()
maze.create(50, 30, 300)
keyboard = Keyboard()
keyboard.key_handlers[key.ESCAPE] = win.close
keyboard.key_handlers.update(camera.key_handlers)
clock.schedule(maze.update)
win.on_draw = lambda: renderer.on_draw(maze, camera, win.width, win.height)
win.on_key_press = keyboard.on_key_press
keyboard.print_handlers()
win.set_visible()
app.run()
开发者ID:msarch,项目名称:py,代码行数:15,代码来源:run.py
示例7: main
def main():
title_screen()
setup_screen()
join_screen()
host_screen()
game_screen()
end_screen()
manager.set_media(mp)
manager.add_widget(my_bg)
game_window.push_handlers(manager)
# Pyglet Settings
schedule_interval(update, 1 / 120.0)
set_fps_limit(120)
run()
开发者ID:nmcalabroso,项目名称:Push,代码行数:15,代码来源:client_push.py
示例8: demo_main
def demo_main(demo_class, size=(640,480), title="Enable Example"):
""" Runs a simple application in Pyglet using an instance of
**demo_class** as the main window or frame.
**demo_class** should be a subclass of DemoFrame or the pyglet
backend's Window class.
"""
if issubclass(demo_class, DemoFrame):
frame = demo_class()
if frame.enable_win is not None:
window = frame.enable_win.control
else:
window = None
else:
window = demo_class().control
if window is not None:
if not window.fullscreen:
window.set_size(*size)
window.set_caption(title)
app.run()
开发者ID:pib,项目名称:enable,代码行数:22,代码来源:example_support.py
示例9: main
def main():
sendQ = Queue()
recvQ = Queue()
#setup net stack
factory = MMFEClient(recvQ=sendQ, sendQ=recvQ, url="ws://localhost:9000", debug=False)
factory.protocol = MMFEClientProtocol
connectWS(factory)
net = Process(target=reactor.run)
#setup game stack
game_window = window.Window()
label = text.Label('Hello, world', font_name='Arial', font_size=16, x=game_window.width//2, y=game_window.height//2, anchor_x='center', anchor_y='center')
@game_window.event
def on_draw():
game_window.clear()
label.draw()
if not recvQ.empty():
data = recvQ.get()
if 'label' in data:
label.text = data['label']
net.start()
app.run()
开发者ID:alex-laties,项目名称:MMFE,代码行数:23,代码来源:core.py
示例10: test
def test(self):
self.window = TestWindow(resizable=True, visible=False)
self.window.set_visible()
app.run()
开发者ID:rougier,项目名称:pyglet,代码行数:4,代码来源:style.py
示例11: main
def main():
#clock.schedule(update)
load()
app.run()
pass
开发者ID:jonathan-beckwith,项目名称:simple-python-roguelike,代码行数:5,代码来源:main.py
示例12: testMultilineFalse
def testMultilineFalse(self):
self.window = TestWindow(
multiline=False, wrap_lines=False,
msg=nonewline_nowrap, resizable=True, visible=False)
self.window.set_visible()
app.run()
开发者ID:bitcraft,项目名称:pyglet,代码行数:6,代码来源:multiline_wrap.py
示例13: testMultilineTrueLimited
def testMultilineTrueLimited(self):
self.window = TestWindow(
multiline=True, wrap_lines=True,
msg=newline_wrap, resizable=True, visible=False)
self.window.set_visible()
app.run()
开发者ID:bitcraft,项目名称:pyglet,代码行数:6,代码来源:multiline_wrap.py
示例14: run
开发者ID:maitred,项目名称:musicapp,代码行数:2,代码来源:musicPlayer.py
示例15: nested
with nested(Projection(0, 0, window.width, window.height, far=1000.0), Matrix, Lighting):
glTranslatef(0, 0, -500)
glRotatef(tilt*0.3, 1.0, 0, 0)
glRotatef(rotate*0.3, 0.0, 1.0, 0)
for body in bodies:
with Matrix:
glMultMatrixf(body.matrix)
cube(size=body.size, color=(0.5, 0.5, 0.5, 1.0))
fps.draw()
description.draw()
keys = pyglet.window.key.KeyStateHandler()
window.push_handlers(keys)
constant = 300.0
def simulate(delta):
for i, body1 in enumerate(bodies):
for body2 in bodies[i+1:]:
vec = body1.position - body2.position
gravity = (body1.mass*body2.mass/vec.magnitude) * constant * delta
normal = vec.normalized
body1.add_force(linear=normal.inversed*gravity, relative=False)
body2.add_force(linear=normal*gravity, relative=False)
world.step(delta, iterations=10)
schedule_interval(simulate, 0.005)
run()
开发者ID:nonameentername,项目名称:pybullet-android,代码行数:30,代码来源:nbody_gravity.py
示例16: run
def run(self):
self.window.set_visible()
app.run()
开发者ID:msarch,项目名称:py,代码行数:3,代码来源:demo.py
示例17: main
def main():
app = PygletApp()
app.run()
开发者ID:msarch,项目名称:py,代码行数:3,代码来源:demo.py
示例18: run
def run(self):
self.dispatch_event('init')
self.dispatch_pending_events()
self.gameWorld.init()
app.run()
开发者ID:rocktavious,项目名称:PyGLEngine,代码行数:5,代码来源:gameclient.py
示例19: pyglet_main
def pyglet_main(liquid):
'''Creates a pyglet window and context that will be 4 times wider and 4
times taller than the simulation area. Pyglet uses asynchronous event
handlers so there are a few functions here to handle those events and
update the simulation variables. The framerate is not tied to the
simulation speed because the simulation is run in it's own thread and
pyglet is tricked into updating at 30Hz.'''
from pyglet.window import mouse, Screen, key
from pyglet import gl, clock, app, graphics
import pyglet.window
import threading
window = pyglet.window.Window(
width = liquid.width * 4, height = liquid.height * 4
)
@window.event
def on_draw():
'''The draw command is one glDraw command after gathering all of the
vertex information from the simulation. The draw loop first draws the
lines in simulation coordinates which is then "scaled" up using
glMatrixmode.'''
window.clear()
vertices = []
colors = []
for p in liquid.particles:
vertices.extend([p.x, p.y, p.x - p.u, p.y - p.v])
colors.extend(p.color)
colors.extend([0, 0, 0])
graphics.draw(
len(liquid.particles)*2,
gl.GL_LINES,
('v2f', vertices),
('c3B', colors)
)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho(0, liquid.width, liquid.height, 0, -1, 1)
gl.glMatrixMode(gl.GL_MODELVIEW)
@window.event
def on_mouse_press(x, y, button, modifiers):
'''Takes mouse press coordinates and sends them to the liquid
simulation object.'''
if button == mouse.LEFT:
liquid.mouse[0] = x/4
liquid.mouse[1] = liquid.height - y/4
liquid.pressed = True
@window.event
def on_mouse_release(x, y, button, modifiers):
'''Tells the liquid simulation to stop tracking the mouse.'''
liquid.pressed = False
@window.event
def on_mouse_drag(x, y, dx, dy, button, modifiers):
'''Updates the liquid simulation mouse coordinates.'''
if button == mouse.LEFT:
liquid.mouse[0] = x/4
liquid.mouse[1] = liquid.height - y/4
stop = threading.Event()
def loop(lt, stop):
'''This is an endless but stoppable loop to run the simulation in a
thread while pyglet handles the drawing and mouse events.'''
while True:
lt.simulate()
if stop.is_set():
break
def induce_paint(dt):
'''This is a dummy function that is added to the pyglet schedule so
that the screen can be updated in a timely fashion independent of the
simulation.'''
pass
worker = threading.Thread(target=loop, args=(liquid, stop))
clock.schedule_interval(induce_paint, 1.0/30.0)
worker.start()
app.run()
stop.set()
worker.join()
开发者ID:ramsay,项目名称:ramsay-snippets,代码行数:81,代码来源:Liquid.py
示例20: start
def start():
configure()
MainWindow()
run()
开发者ID:ceronman,项目名称:prisionescape,代码行数:4,代码来源:game.py
注:本文中的pyglet.app.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论