本文整理汇总了Python中pyglet.window.key.S属性的典型用法代码示例。如果您正苦于以下问题:Python key.S属性的具体用法?Python key.S怎么用?Python key.S使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pyglet.window.key
的用法示例。
在下文中一共展示了key.S属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [as 别名]
def on_key_press(self, symbol, modifiers):
mod = 1
if modifiers & key.MOD_SHIFT:
mod = -1
if symbol == key.M:
self.multisample = not self.multisample
self.set_window()
if symbol == key.S:
self.samples += 2 * mod
self.samples = max(2, self.samples)
self.set_window()
# Another test: try enabling/disabling GL_MULTISAMPLE_ARB...
# seems to have no effect if samples > 4.
if symbol == key.N:
self.soft_multisample = not self.soft_multisample
if self.soft_multisample:
print 'Enabling GL_MULTISAMPLE_ARB'
glEnable(GL_MULTISAMPLE_ARB)
else:
print 'Disabling GL_MULTISAMPLE_ARB'
glDisable(GL_MULTISAMPLE_ARB)
示例2: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [as 别名]
def on_key_press(self, symbol, modifiers):
mod = 1
if modifiers & key.MOD_SHIFT:
mod = -1
if symbol == key.M:
self.multisample = not self.multisample
self.set_window()
if symbol == key.S:
self.samples += 2 * mod
self.samples = max(2, self.samples)
self.set_window()
# Another test: try enabling/disabling GL_MULTISAMPLE_ARB...
# seems to have no effect if samples > 4.
if symbol == key.N:
self.soft_multisample = not self.soft_multisample
if self.soft_multisample:
print('Enabling GL_MULTISAMPLE_ARB')
glEnable(GL_MULTISAMPLE_ARB)
else:
print('Disabling GL_MULTISAMPLE_ARB')
glDisable(GL_MULTISAMPLE_ARB)
示例3: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [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.S and (modifiers & key.LCTRL):
scene_file = load()
self.shader = Shader(["./glsl/fractal3d.vert"], [scene_file])
self.init_shader()
示例4: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [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()
示例5: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [as 别名]
def on_key_press(symbol, modifiers):
global enable_shader
global enable_bidirectional
global enable_antialias
global enable_outline
global enable_glow
global outline_width
global glow_width
if symbol == key.S:
enable_shader = not enable_shader
elif symbol == key.B:
enable_bidirectional = not enable_bidirectional
elif symbol == key.A:
enable_antialias = not enable_antialias
elif symbol == key.O:
enable_outline = not enable_outline
enable_glow = False
elif symbol == key.G:
enable_glow = not enable_glow
enable_outline = False
elif symbol == key.PERIOD:
if enable_glow:
glow_width += 0.005
else:
outline_width += 0.005
elif symbol == key.COMMA:
if enable_glow:
glow_width -= 0.005
else:
outline_width -= 0.005
print('-' * 78)
print('enable_shader', enable_shader)
print('enable_bidirectional', enable_bidirectional)
print('enable_antialias', enable_antialias)
print('enable_outline', enable_outline)
print('enable_glow', enable_glow)
print('outline_width', outline_width)
示例6: test_question_skip
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [as 别名]
def test_question_skip(event_loop):
event_loop.create_window()
event_loop.ask_question('Please press S to skip the rest of this test.')
pytest.fail('You should have pressed S')
示例7: __init__
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [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 = {}
示例8: update
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [as 别名]
def update(self, dt):
# Fall into water if there's too much under our feet
if self.water_tiles >= 4:
self.falling += FALL_RATE * dt
# If we're on full land, climb back up
if self.water_tiles == 0 and self.falling > 0:
self.falling -= FALL_RATE * 2 * dt
if self.falling:
self.falling += FALL_RATE * dt
self.update_size()
if self.falling > FALL_MAX:
self.game_over(fell=True)
self.water_tiles = 0
self.previous_coordinates = (self.x, self.y)
if keys[key.W]:
self.y += dt * self.speed
if keys[key.S]:
self.y -= dt * self.speed
if keys[key.A]:
self.x -= dt * self.speed
if keys[key.D]:
self.x += dt * self.speed
if self.firing:
self.fire()
示例9: on_key_release
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [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()
示例10: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import S [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')