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


Python key.RIGHT属性代码示例

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


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

示例1: pyglet_key_down

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def pyglet_key_down(self, symbol, modifier, repeat_in=0.3):
        from pyglet.window import key
        self.last_key_down = symbol
        self.last_key_modifier = modifier
        self.next_key_repeat = time.time() + repeat_in
        is_ascii = 27 <= symbol < 255
        char = {
            key.LEFT: KEYS.LEFT_ARROW,
            key.RIGHT: KEYS.RIGHT_ARROW,
            key.UP: KEYS.UP_ARROW,
            key.DOWN: KEYS.DOWN_ARROW,
            key.ENTER: '\r',
            key.RETURN: '\r',
            key.BACKSPACE: chr(127),
        }.get(symbol, chr(symbol) if is_ascii else None)
        if not char:
            # All other characters don't count as a key press
            # (e.g., function keys, modifier keys, etc.)
            return
        if modifier & key.MOD_SHIFT:
            char = char.upper()
        self.set_needs_display()
        self.handle_input(char) 
开发者ID:PartnershipOnAI,项目名称:safelife,代码行数:25,代码来源:interactive_game.py

示例2: update

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def update(self, dt):
        # Do all the normal physics stuff
        super(Player, self).update(dt)

        if self.key_handler[key.LEFT]:
            self.rotation -= self.rotate_speed * dt
        if self.key_handler[key.RIGHT]:
            self.rotation += self.rotate_speed * dt

        if self.key_handler[key.UP]:
            # Note: pyglet's rotation attributes are in "negative degrees"
            angle_radians = -math.radians(self.rotation)
            force_x = math.cos(angle_radians) * self.thrust * dt
            force_y = math.sin(angle_radians) * self.thrust * dt
            self.velocity_x += force_x
            self.velocity_y += force_y

            # If thrusting, update the engine sprite
            self.engine_sprite.rotation = self.rotation
            self.engine_sprite.x = self.x
            self.engine_sprite.y = self.y
            self.engine_sprite.visible = True
        else:
            # Otherwise, hide it
            self.engine_sprite.visible = False 
开发者ID:Akagi201,项目名称:learning-python,代码行数:27,代码来源:player.py

示例3: _get_mouse_button_and_modifiers

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def _get_mouse_button_and_modifiers(ev):
        button = EventMouseButton()
        carbon.GetEventParameter(ev, kEventParamMouseButton,
            typeMouseButton, c_void_p(), sizeof(button), c_void_p(),
            byref(button))

        if button.value == 1:
            button = mouse.LEFT
        elif button.value == 2:
            button = mouse.RIGHT
        elif button.value == 3:
            button = mouse.MIDDLE
        else:
            button = None

        modifiers = c_uint32()
        carbon.GetEventParameter(ev, kEventParamKeyModifiers,
            typeUInt32, c_void_p(), sizeof(modifiers), c_void_p(),
            byref(modifiers))

        return button, CarbonWindow._map_modifiers(modifiers.value) 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:23,代码来源:__init__.py

示例4: update

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def update(self, dt):
        # Do all the normal physics stuff
        super(Player, self).update(dt)

        if self.key_handler[key.LEFT]:
            self.rotation -= self.rotate_speed * dt
        if self.key_handler[key.RIGHT]:
            self.rotation += self.rotate_speed * dt

        if self.key_handler[key.UP]:
            angle_radians = -math.radians(self.rotation)
            force_x = math.cos(angle_radians) * self.thrust * dt
            force_y = math.sin(angle_radians) * self.thrust * dt
            self.velocity_x += force_x
            self.velocity_y += force_y

            # If thrusting, update the engine sprite
            self.engine_sprite.rotation = self.rotation
            self.engine_sprite.x = self.x
            self.engine_sprite.y = self.y
            self.engine_sprite.visible = True
        else:
            # Otherwise, hide it
            self.engine_sprite.visible = False 
开发者ID:pyglet,项目名称:pyglet,代码行数:26,代码来源:player.py

示例5: move_camera

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def move_camera(dt):
    camera_speed = 3
    if keys[key.LEFT]:
        scene.camera.position.x -= camera_speed * dt
    if keys[key.RIGHT]:
        scene.camera.position.x += camera_speed * dt 
开发者ID:ratcave,项目名称:ratcave,代码行数:8,代码来源:tutorial2.py

示例6: key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def key_press(k, mod):
        global restart
        if k==0xff0d: restart = True
        if k==key.LEFT:  a[0] = -1.0
        if k==key.RIGHT: a[0] = +1.0
        if k==key.UP:    a[1] = +1.0
        if k==key.DOWN:  a[2] = +0.8   # set 1.0 for wheels to block to zero rotation 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:9,代码来源:car_racing.py

示例7: key_release

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def key_release(k, mod):
        if k==key.LEFT  and a[0]==-1.0: a[0] = 0
        if k==key.RIGHT and a[0]==+1.0: a[0] = 0
        if k==key.UP:    a[1] = 0
        if k==key.DOWN:  a[2] = 0 
开发者ID:ArztSamuel,项目名称:DRL_DeliveryDuel,代码行数:7,代码来源:car_racing.py

示例8: on_text_motion

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def on_text_motion(self, motion): 
        if motion == key.UP:
            self.xRotation -= INCREMENT
        elif motion == key.DOWN:
            self.xRotation += INCREMENT
        elif motion == key.LEFT:
            self.yRotation -= INCREMENT
        elif motion == key.RIGHT:
            self.yRotation += INCREMENT 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-Cookbook-Second-Edition,代码行数:11,代码来源:pyglet_GUI.py

示例9: key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def key_press(self, k, mod):
        if k==key.LEFT:  self.move[0] = True
        if k==key.RIGHT: self.move[1] = True
        if k==key.UP:    self.move[2] = True
        if k==key.DOWN:  self.move[3] = True 
开发者ID:openai,项目名称:multiagent-particle-envs,代码行数:7,代码来源:policy.py

示例10: key_release

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def key_release(self, k, mod):
        if k==key.LEFT:  self.move[0] = False
        if k==key.RIGHT: self.move[1] = False
        if k==key.UP:    self.move[2] = False
        if k==key.DOWN:  self.move[3] = False 
开发者ID:openai,项目名称:multiagent-particle-envs,代码行数:7,代码来源:policy.py

示例11: on_key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def on_key_press(symbol, modifiers):
    """
    This handler processes keyboard commands that
    control the simulation
    """

    if symbol == key.BACKSPACE or symbol == key.SLASH:
        print('RESET')
        env.reset()
        env.render('pyglet', view=view_mode)
        return

    if symbol == key.ESCAPE:
        env.close()
        sys.exit(0)

    if symbol == key.UP:
        step(env.actions.move_forward)
    elif symbol == key.DOWN:
        step(env.actions.move_back)

    elif symbol == key.LEFT:
        step(env.actions.turn_left)
    elif symbol == key.RIGHT:
        step(env.actions.turn_right)

    elif symbol == key.PAGEUP or symbol == key.P:
        step(env.actions.pickup)
    elif symbol == key.PAGEDOWN or symbol == key.D:
        step(env.actions.drop)

    elif symbol == key.ENTER:
        step(env.actions.done) 
开发者ID:maximecb,项目名称:gym-miniworld,代码行数:35,代码来源:manual_control.py

示例12: on_mouse_drag

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def on_mouse_drag(self, x, y, dx, dy, button, modifiers):
        self.io.mouse_pos = x, self.io.display_size.y - y

        if button == mouse.LEFT:
            self.io.mouse_down[0] = 1

        if button == mouse.MIDDLE:
            self.io.mouse_down[1] = 1

        if button == mouse.RIGHT:
            self.io.mouse_down[2] = 1 
开发者ID:swistakm,项目名称:pyimgui,代码行数:13,代码来源:pyglet.py

示例13: on_mouse_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def on_mouse_press(self, x, y, button, modifiers):
        self.io.mouse_pos = x, self.io.display_size.y - y

        if button == mouse.LEFT:
            self.io.mouse_down[0] = 1

        if button == mouse.MIDDLE:
            self.io.mouse_down[1] = 1

        if button == mouse.RIGHT:
            self.io.mouse_down[2] = 1 
开发者ID:swistakm,项目名称:pyimgui,代码行数:13,代码来源:pyglet.py

示例14: on_mouse_release

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def on_mouse_release(self, x, y, button, modifiers):
        self.io.mouse_pos = x, self.io.display_size.y - y

        if button == mouse.LEFT:
            self.io.mouse_down[0] = 0

        if button == mouse.MIDDLE:
            self.io.mouse_down[1] = 0

        if button == mouse.RIGHT:
            self.io.mouse_down[2] = 0 
开发者ID:swistakm,项目名称:pyimgui,代码行数:13,代码来源:pyglet.py

示例15: on_key_press

# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import RIGHT [as 别名]
def on_key_press(self, symbol, modifiers):
        if symbol == key.LEFT or symbol == key.RIGHT:
            self.value = not self.value
            self.text.text = self.get_label()
            self.toggle_func(self.value)
            if enable_sound:
                bullet_sound.play() 
开发者ID:shrimpboyho,项目名称:flappy-bird-py,代码行数:9,代码来源:astraea.py


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