• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python window.Window类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


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


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


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


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


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


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


示例16: prepare

    def prepare(self, options):
        self.window = Window(
            fullscreen=options.fullscreen,
            vsync=options.vsync,
            visible=False,
            resizable=True)
        self.window.on_draw = self.draw_window

        self.world = World()
        self.player = Player(self.world)
        self.camera = GameItem(
            position=origin,
            update=CameraMan(self.player, (3, 2, 0)),
        )
        self.level_loader = Level(self)
        success = self.start_level(1)
        if not success:
            logging.error("ERROR, can't load level 1")
            sys.exit(1)

        self.update(1/60)

        self.window.push_handlers(KeyHandler(self.player))

        self.render = Render(self.world, self.window, self.camera)
        self.render.init()

        self.music = Music()
        self.music.load()
        self.music.play()
开发者ID:mjs,项目名称:pyweek11-cube,代码行数:30,代码来源:gameloop.py


示例17: prepare

    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()
开发者ID:msarch,项目名称:py,代码行数:29,代码来源:gameloop.py


示例18: __init__

 def __init__(self, size=(DEFAULT_WIDTH, DEFAULT_HEIGHT),
         title='MegaMinerAI Bland Title Text', fullscreen=False):
     self.window = Window(width=size[0], height=size[1], caption=title,
             visible=True, fullscreen=fullscreen, resizable=True,
             style=Window.WINDOW_STYLE_DEFAULT, vsync=False, display=None,
             context=None, config=None)
     self.updates = []
开发者ID:jason-rossmaier,项目名称:visualizer,代码行数:7,代码来源:application.py


示例19: run

    def run(self, name, texture):

        #Sets up name and texture
        self.texture = texture
        self.name = name

        #Sets up images
        self.block_textures = pyglet.image.load(os.getcwd()+"/Resources"+self.texture+"Blocks/Textures.png")
        self.blocks_textures = pyglet.image.ImageGrid(self.block_textures, 5, 1)

        #Reads data
        self.extract_data()

        #Generates tiles and stuff
        self.generate_map()
        
        #Sets up window
        self.window = Window(800,600)
        self.window.set_icon(self.blocks_textures[1])

        #Generates sprites to show at start
        self.screen_render_start(0,0)

        #Runs it
        pyglet.app.run()
开发者ID:JacobWeinbren,项目名称:Space_Project,代码行数:25,代码来源:Display.py


示例20: setUp

 def setUp(self):
     self.window = Window(
         width=200, height=100, visible=False, caption="Camera_test setup")
     self.window.dispatch_events()
     glClearColor(0, 0, 0, 1)
     self.window.clear()
     self.world = World()
     self.camera = Camera((0, 0), 1)
开发者ID:tartley,项目名称:sole-scion,代码行数:8,代码来源:camera_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python key.modifiers_string函数代码示例发布时间:2022-05-25
下一篇:
Python text.Label类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap