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


Python key.SPACE属性代码示例

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


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

示例1: on_key_release

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def on_key_release(symbol, modifiers):
    global player

    global bigScreen
    global smallScreen

    if symbol == key.SPACE:
        player.jump()

    if symbol == key.PAGEUP:
        if smallScreen == True:
                glScalef(2.0, 2.0, 2.0)
                window.set_size(window.width * 2, window.height * 2)
                smallScreen = False
                bigScreen = True
    if symbol == key.PAGEDOWN:
            if bigScreen:
                glScalef(0.5, 0.5, 0.5)
                window.set_size(window.width / 2 , window.height /2)
                smallScreen = True
                bigScreen = False

# Handle mouse presses 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:25,代码来源:window.py

示例2: on_key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def on_key_press(self, symbol, modifiers):
        """
        Keyboard interface.
        """
        if symbol == key.ENTER:
            self.save_screenshot()

        if symbol == key.ESCAPE:
            pyglet.app.exit()

        if symbol == key.SPACE:
            self.clear_blank_window()

        if symbol == key.P:
            self.use_random_palette()

        if symbol == key.S and not modifiers:
            self.use_next_species()

        if symbol == key.S and (modifiers & key.LCTRL):
            self.save_config()

        if symbol == key.O and (modifiers & key.LCTRL):
            self.require_config_input()

        if symbol == key.V and (modifiers & key.LCTRL):
            self.switch_video() 
开发者ID:neozhaoliang,项目名称:pywonderland,代码行数:29,代码来源:main.py

示例3: on_key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def on_key_press(self, symbol, modifiers):
        if symbol == key.SPACE:
            self.fire() 
开发者ID:Akagi201,项目名称:learning-python,代码行数:5,代码来源:player.py

示例4: on_key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def on_key_press(symbol, modifiers):
    if symbol == key.SPACE:
        balls.append(Ball())
    elif symbol == key.BACKSPACE:
        if balls:
            del balls[-1]
    elif symbol == key.ESCAPE:
        window.has_exit = True 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:10,代码来源:noisy.py

示例5: on_key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def on_key_press(self, symbol, modifiers):
        if symbol == key.SPACE:
            self.on_play_pause()
        elif symbol == key.ESCAPE:
            self.dispatch_event('on_close') 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:7,代码来源:media_player.py

示例6: on_key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def on_key_press(self, symbol, modifiers):
        if symbol == key.SPACE:
            self.on_play_pause()
        elif symbol == key.ESCAPE:
            self.dispatch_event('on_close')
        elif symbol == key.LEFT:
            self.player.seek(0)
        elif symbol == key.RIGHT:
            self.player.next_source() 
开发者ID:pyglet,项目名称:pyglet,代码行数:11,代码来源:media_player.py

示例7: __init__

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def __init__(self, character=characters.Bomber, agent_control='arrows'):
        super(PlayerAgent, self).__init__(character)

        ##
        # @NOTE: DO NOT move this import outside the constructor. It will
        # not work in headless environments like a Docker container
        # and prevents Pommerman from running.
        #
        from pyglet.window import key
        controls = {
            'arrows': {
                key.UP: 1,
                key.DOWN: 2,
                key.LEFT: 3,
                key.RIGHT: 4,
                key.SPACE: 5,
                key.M: 6  # In Pommerman, this will freeze the game.
            },
            'wasd': {
                key.W: 1,
                key.S: 2,
                key.A: 3,
                key.D: 4,
                key.E: 5,
                key.Q: 6  # In Pommerman, this will freeze the game.
            }
        }

        assert agent_control in controls, "Unknown control: {}".format(
            agent_control)
        self._key2act = controls[agent_control]

        self._action_q = []
        self._keystate = {} 
开发者ID:MultiAgentLearning,项目名称:playground,代码行数:36,代码来源:player_agent.py

示例8: on_key_release

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def on_key_release(self, symbol, modifiers):
        """Event handler for the Window.on_key_release event.

        Called when the player releases a key. See pyglet docs for key
        mappings.

        Parameters
        ----------
        symbol : int
            Number representing the key that was pressed.
        modifiers : int
            Number representing any modifying keys that were pressed.

        """
        if symbol == key.W:
            self.strafe[0] += 1
        elif symbol == key.S:
            self.strafe[0] -= 1
        elif symbol == key.A:
            self.strafe[1] += 1
        elif symbol == key.D:
            self.strafe[1] -= 1
        elif symbol == key.SPACE:
            self.dy = 0
        elif symbol == key.LCTRL:
            self.running = False
        elif symbol == key.LSHIFT:
            self.dy = 0
        elif symbol == key.P:
            breakpoint() 
开发者ID:XenonLab-Studio,项目名称:TerraCraft,代码行数:32,代码来源:scenes.py

示例9: on_key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import SPACE [as 别名]
def on_key_press(self, symbol, modifiers):
        """Event handler for the Window.on_key_press event.

        Called when the player presses a key. See pyglet docs for key
        mappings.

        Parameters
        ----------
        symbol : int
            Number representing the key that was pressed.
        modifiers : int
            Number representing any modifying keys that were pressed.

        """
        if symbol == key.W:
            self.strafe[0] -= 1
        elif symbol == key.S:
            self.strafe[0] += 1
        elif symbol == key.A:
            self.strafe[1] -= 1
        elif symbol == key.D:
            self.strafe[1] += 1
        elif symbol == key.SPACE:
            if self.flying:
                # Reduces vertical flying speed
                # 0.1 positive value that allows vertical flight up.
                self.dy = 0.1 * JUMP_SPEED
            elif self.dy == 0:
                self.dy = JUMP_SPEED
                self.audio.play(self.jump_sfx)
        elif symbol == key.LCTRL:
            self.running = True
        elif symbol == key.LSHIFT:
            if self.flying:
                # Reduces vertical flying speed
                # -0.1 negative value that allows vertical flight down.
                self.dy = -0.1 * JUMP_SPEED
            elif self.dy == 0:
                self.dy = JUMP_SPEED
        elif symbol == key.ESCAPE:
            self.set_exclusive_mouse(False)
            return pyglet.event.EVENT_HANDLED
        elif symbol == key.TAB:
            self.flying = not self.flying
        elif symbol == key.F1:
            self.scene_manager.change_scene("HelpScene")
        elif symbol == key.F2:
            self.toggleGui = not self.toggleGui
        elif symbol == key.F3:
            self.toggleLabel = not self.toggleLabel
        elif symbol == key.F5:
            self.scene_manager.save.save_world(self.model)
        elif symbol == key.F12:
            pyglet.image.get_buffer_manager().get_color_buffer().save('screenshot.png')
        elif symbol in self.num_keys:
            index = (symbol - self.num_keys[0]) % len(self.inventory)
            self.block = self.inventory[index]
        elif symbol == key.ENTER:
            self.scene_manager.change_scene('MenuScene') 
开发者ID:XenonLab-Studio,项目名称:TerraCraft,代码行数:61,代码来源:scenes.py


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