当前位置: 首页>>代码示例>>Python>>正文


Python Window.on_draw方法代码示例

本文整理汇总了Python中pyglet.window.Window.on_draw方法的典型用法代码示例。如果您正苦于以下问题:Python Window.on_draw方法的具体用法?Python Window.on_draw怎么用?Python Window.on_draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyglet.window.Window的用法示例。


在下文中一共展示了Window.on_draw方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from pyglet.window import Window [as 别名]
# 或者: from pyglet.window.Window import on_draw [as 别名]
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,代码行数:15,代码来源:demo.py

示例2: main

# 需要导入模块: from pyglet.window import Window [as 别名]
# 或者: from pyglet.window.Window import on_draw [as 别名]
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,代码行数:17,代码来源:run.py

示例3: make_army

# 需要导入模块: from pyglet.window import Window [as 别名]
# 或者: from pyglet.window.Window import on_draw [as 别名]
def make_army(size, menagerie):
    army = []
    for col in range(size):
        for row in range(size):
            creature_type = menagerie[randint(0, len(menagerie)-1)]
            x = (col+0.5)*16 - size * 8
            y = (row+0.5)*16 - size * 8
            creature = Creature(creature_type, (x, y))
            creature.da = uniform(-0.1, +0.1)
            creature.velocity = uniform(0, +0.5)
            army.append(creature)
    return army

creatures = make_army(12, [blue_ghost, orange_ghost, pacman, pink_ghost, red_ghost])

def update(dt):
    for creature in creatures:
        creature.update(dt)

clock.schedule(update)

key_handlers[key.ESCAPE] = win.close
win.on_draw = lambda: renderer.on_draw(creatures, camera, win.width, win.height)
win.on_key_press = on_key_press

print "keys to try:", [symbol_string(k) for k in key_handlers.keys()]
stdout.flush()
win.set_visible()
app.run()

开发者ID:msarch,项目名称:py,代码行数:31,代码来源:run.py

示例4: Window

# 需要导入模块: from pyglet.window import Window [as 别名]
# 或者: from pyglet.window.Window import on_draw [as 别名]
from renderer import Renderer

win = Window(fullscreen=True, visible=False)
camera = Camera((0, 0), 10)
renderer = Renderer()

army_shape = Army.MakeShape(400, 1500, all_ghosts)
armies = []
for i in range(20, 0, -1):
    army = Creature(army_shape, rand_point(500), uniform(-pi, pi))
    army.dx = uniform(-0.4, +0.4)
    army.dy = uniform(-0.4, +0.4)
    armies.append(army)

def update(dt):
    for army in armies:
        army.update(dt)
    camera.zoom(1.003)

clock.schedule(update)

key_handlers[key.ESCAPE] = win.close
win.on_draw = lambda: renderer.on_draw(armies, camera, win.width, win.height)
win.on_key_press = on_key_press

print "keys to try:", [symbol_string(k) for k in key_handlers.keys()]
stdout.flush()
win.set_visible()
app.run()

开发者ID:msarch,项目名称:py,代码行数:31,代码来源:run.py


注:本文中的pyglet.window.Window.on_draw方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。