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


Python window.Window类代码示例

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


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

示例1: main

def main():
    global win
    clock.schedule(rabbyt.add_time)

    win = Window(width=800, height=600)
    rabbyt.set_default_attribs()

    lawn = Lawn()
    wind = Wind()

    magicEventRegister(win, events, list(lawn))

    while not win.has_exit:
        tick = clock.tick()
        win.dispatch_events()

        lawn.update(tick)
        wind.update(tick)
        events.ConsumeEventQueue()

        rabbyt.clear((1, 1, 1))

        lawn.draw()

        win.flip()
开发者ID:pdevine,项目名称:suburbia,代码行数:25,代码来源:gutter.py

示例2: main

def main():
    global fps_display

    win = Window(width=800, height=600)

    clock.schedule(rabbyt.add_time)

    rabbyt.set_default_attribs()

    bg = Background()

    fps_display = clock.ClockDisplay()

    while not win.has_exit:
        tick = clock.tick()
        win.dispatch_events()

        bg.update(tick)

        rabbyt.clear((bg.color))

        bg.draw()
        fps_display.draw()

        win.flip()
开发者ID:pdevine,项目名称:suburbia,代码行数:25,代码来源:sky.py

示例3: main

def main():
    # Create the main window
    window = Window(800, 600, visible=False,
                   caption="FF:Tactics.py", style='dialog')
    # Create the default camera and have it always updating
    camera = Camera((-600, -300, 1400, 600), (400, 300), 300, speed=PEPPY)
    clock.schedule(camera.update)

    # Load the first scene
    world = World(window, camera)
    world.transition(MainMenuScene)

    # centre the window on whichever screen it is currently on
    window.set_location(window.screen.width/2 - window.width/2,
                        window.screen.height/2 - window.height/2)
    # clear and flip the window
    # otherwise we see junk in the buffer before the first frame
    window.clear()
    window.flip()

    # make the window visible at last
    window.set_visible(True)

    # finally, run the application
    pyglet.app.run()
开发者ID:johnmendel,项目名称:python-tactics,代码行数:25,代码来源:tactics.py

示例4: 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

示例5: Gameloop

class Gameloop(object):

    def __init__(self):
        self.window = None

    def init(self):
        self.world = World()
        self.world.init()
        populate(self.world)

        bitmaps = Bitmaps()
        bitmaps.load()
        self.render = Render(bitmaps)
        self.camera = Camera(zoom=10.0)

        self.window = Window(fullscreen=False, visible=False)
        self.window.set_exclusive_mouse(True)
        self.window.on_draw = self.draw
        self.window.on_resize = self.render.resize

        self.controls = Controls(self.world.bat)
        self.window.set_handlers(self.controls)

        self.render.init()
        clock.schedule(self.update)
        self.hud_fps = clock.ClockDisplay()

        self.window.set_visible()


    def update(self, dt):
        # scale dt such that the 'standard' framerate of 60fps gives dt=1.0
        dt *= 60.0
        # don't attempt to compensate for framerate of less than 30fps. This
        # guards against huge explosion when game is paused for any reason
        # and then restarted
        dt = min(dt, 2)
        self.controls.update()
        self.world.update()
        self.window.invalid = True

    def draw(self):
        self.window.clear()
        self.camera.world_projection(self.window.width, self.window.height)
        self.camera.look_at()
        self.render.draw(self.world)

        self.hud_fps.draw()

        return EVENT_HANDLED

    def stop(self):
        if self.window:
            self.window.close()
开发者ID:tartley,项目名称:pyong,代码行数:54,代码来源:gameloop.py

示例6: Gameloop

class Gameloop(object):
    def __init__(self):
        self.camera = None
        self.projection = None
        self.render = None
        self.window = None
        self.world = None
        self.fpss = []

    def prepare(self, options):
        self.window = Window(fullscreen=options.fullscreen, vsync=False, visible=False, resizable=True)
        self.window.on_draw = self.draw
        self.projection = Projection(self.window.width, self.window.height)
        self.window.on_resize = self.projection.resize

        self.world = World()

        self.camera = Camera()
        self.world.add(GameItem(camera=self.camera, position=Origin, move=WobblyOrbit(32, 1, speed=-0.5)))

        self.render = Render(self.world)
        self.render.init()
        pyglet.clock.schedule(self.update)
        self.clock_display = pyglet.clock.ClockDisplay()

        vs = VertexShader(join("flyinghigh", "shaders", "lighting.vert"))
        fs = FragmentShader(join("flyinghigh", "shaders", "lighting.frag"))
        shader = ShaderProgram(vs, fs)
        shader.use()

    def update(self, dt):
        # self.fpss.append(1/max(1e-3, dt))
        dt = min(dt, 1 / 30)
        self.world.update(dt)
        self.window.invalid = True

    def draw(self):
        self.window.clear()

        self.projection.set_perspective(45)
        self.camera.look_at(Origin)
        self.render.draw()

        self.projection.set_screen()
        self.camera.reset()
        self.render.draw_hud(self.clock_display)

        return EVENT_HANDLED

    def stop(self):
        if self.window:
            self.window.close()
开发者ID:tartley,项目名称:flyinghigh-opengl-from-python,代码行数:52,代码来源:gameloop.py

示例7: 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

示例8: _create_shadow_window

def _create_shadow_window():
    global _shadow_window

    import pyglet
    if not pyglet.options['shadow_window'] or _is_epydoc:
        return
    
    from pyglet.window import Window
    _shadow_window = Window(width=1, height=1, visible=False)
    _shadow_window.switch_to()

    from pyglet import app
    app.windows.remove(_shadow_window)
开发者ID:cajlarsson,项目名称:village,代码行数:13,代码来源:__init__.py

示例9: __init__

 def __init__(self, view_size=(10,10),scale=(10),*args, **kwargs):
     Window.__init__(self, *args, **kwargs)
     self.set_mouse_visible(True)
     
     self.view_scale = scale#min(self.width/view_size[0],self.height/view_size[1])
     self.view_size = view_size
     
     self.undo = UndoManager(self)
     
     self.width = self.view_scale*self.view_size[0]
     self.height = self.view_scale*self.view_size[1]
     
     self.setup()
开发者ID:Hugoagogo,项目名称:squiglet,代码行数:13,代码来源:editor.py

示例10: PygletApp

class PygletApp(object):

    def __init__(self):
        self.window = Window(visible=False, fullscreen=False)
        self.window.on_resize = self.on_resize
        self.window.on_draw = self.on_draw
        self.window.on_key_press = self.on_key_press

        self.files = SvgFiles()

        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        gluLookAt(
            0.0, -0.0, 1.0,  # eye
            0.0, -0.0, -1.0, # lookAt
            0.0, 1.0, 0.0)  # up


    def on_draw(self):
        glClear(GL_COLOR_BUFFER_BIT)
        self.files.draw()
        return EVENT_HANDLED


    def on_resize(self, width, height):
        # scale is distance from screen centre to top or bottom, in world coords
        scale = 110
        glMatrixMode(GL_PROJECTION)
        glLoadIdentity()
        aspect = width / height
        gluOrtho2D(
            -scale * aspect,
            +scale * aspect,
            -scale,
            +scale)
        return EVENT_HANDLED


    def on_key_press(self, symbol, modifiers):
        if symbol == key.ESCAPE:
            self.window.close()
            return
        self.files.next()


    def run(self):
        self.window.set_visible()
        app.run()
开发者ID:msarch,项目名称:py,代码行数:48,代码来源:demo.py

示例11: __init__

    def __init__(self):
        self.win = Window(fullscreen=True, visible=False)
        self.clockDisplay = clock.ClockDisplay()
        glClearColor(0.2, 0.2, 0.2, 1)
        self.camera = Camera((0, 0), 250)

        self.space = pymunk.Space() #2
        self.space.gravity = (0, -500.0)
        self.space.damping = 0.999

        self.map = alone.Map(self.space)

        self.player = alone.Player(*self.map.to_world(1,2))
        self.space.add(self.player.box, self.player.body)
        self.space.add_collision_handler(0, 0, None, None, self.print_collision, None)

        self.balls = []

        self.lamps = [alone.Lamp(*self.map.to_world(4, 3))]

        #self.powerups = [alone.Powerup(*self.map.to_world(1, 4))]

        darkImage = pyglet.resource.image('dark.png')
        winSize = self.win.get_size()

        self.darkness = pyglet.sprite.Sprite(darkImage, x=0, y=0)
        self.darkness.scale = winSize[0]/darkImage.width
        
        backgroundImage = pyglet.resource.image('background.png')
        self.background = pyglet.sprite.Sprite(backgroundImage, x=0, y=0)
        self.background.scale = winSize[0]/backgroundImage.width

        self.camera.setTarget(0, 0)
开发者ID:kragniz,项目名称:ld48-22,代码行数:33,代码来源:main.py

示例12: setUp

 def setUp(self):
     self.w = Window(width=1, height=1, visible=False)
     self.s = Sprite(10, 10, 10, 10,
                     Image2d.from_image(SolidColorImagePattern((0, 0, 0,
                                                                0)).create_image(
                         1, 1)))
     assert (self.s.x, self.s.y) == (10, 10)
开发者ID:bitcraft,项目名称:pyglet,代码行数:7,代码来源:SPRITE_MODEL.py

示例13: __init__

    def __init__(self, pmap):
        self.world = World(pmap)
        self.win = Window(width=pmap['bounds'][2], height=pmap['bounds'][3])
#        pyglet.clock.set_fps_limit(10)
#        pyglet.clock.set_fps_limit(60)
        self.win.push_handlers(self.on_key_press)
        self.fullscreen = False
开发者ID:ajhalme,项目名称:maplabel,代码行数:7,代码来源:Maplabel.py

示例14: __init__

    def __init__(self):
        vs = True  # limit FPS or something

        try:
            # Try and create a window with multisampling (antialiasing)
            config = Config(sample_buffers=1, samples=4, 
                          depth_size=16, double_buffer=True,)
            GLWindow.__init__(self, self.sizeX, self.sizeY, vsync=vs, 
                              resizable=False, config=config)
        except pyglet.window.NoSuchConfigException:
            # Fall back to no multisampling for old hardware
            super(Melee, self).__init__(self.sizeX, self.sizeY, vsync=vs, 
                                        resizable=False)
        
        # Initialize OpenGL
        squirtle.setup_gl()
开发者ID:greenm01,项目名称:openmelee,代码行数:16,代码来源:gl.py

示例15: launch

    def launch(self):
        self.win = Window(
            width=1024, height=768,
            vsync=self.vsync,
            visible=False)
        self.win.set_mouse_visible(False)
        GameItem.win = self.win

        load_sounds()

        self.music = Music()
        self.music.load()
        self.music.play()

        keystate = key.KeyStateHandler()
        self.win.push_handlers(keystate)

        game = Game(keystate, self.win.width, self.win.height)

        handlers = {
            key.M: self.toggle_music,
            key.F4: self.toggle_vsync,
            key.ESCAPE: self.exit,
        }
        game.add(KeyHandler(handlers))

        render = Render(game)
        render.init(self.win)
        game.startup(self.win)
        self.win.set_visible()
        pyglet.app.run()
开发者ID:mjs,项目名称:brokenspell,代码行数:31,代码来源:application.py


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