本文整理汇总了Python中pyglet.window.key._1属性的典型用法代码示例。如果您正苦于以下问题:Python key._1属性的具体用法?Python key._1怎么用?Python key._1使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pyglet.window.key
的用法示例。
在下文中一共展示了key._1属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import _1 [as 别名]
def on_key_press(self, symbol, modifiers):
if symbol == key._1:
self.apply = not self.apply
with self.shader:
self.shader.uniformi("iApply", self.apply)
if symbol == key._2:
self.hyperbolic = not self.hyperbolic
with self.shader:
self.shader.uniformi("iHyperbolic", self.hyperbolic)
if symbol == key._3:
self.elliptic = not self.elliptic
with self.shader:
self.shader.uniformi("iElliptic", self.elliptic)
if symbol == key.V and (modifiers & key.LCTRL):
self.switch_video()
if symbol == key.ENTER:
self.save_screenshot()
if symbol == key.ESCAPE:
pyglet.app.exit()
示例2: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import _1 [as 别名]
def on_key_press(self, symbol, modifiers):
fullscreen = not modifiers & key.MOD_CTRL
doing = fullscreen and 'Setting' or 'Restoring from'
if symbol == key._0:
print('%s default size' % doing)
self.w.set_fullscreen(fullscreen)
return
elif symbol == key._1:
width, height = 320, 200
elif symbol == key._2:
width, height = 640, 480
elif symbol == key._3:
width, height = 800, 600
elif symbol == key._4:
width, height = 1024, 768
elif symbol == key._5:
width, height = 1280, 800 # 16:10
elif symbol == key._6:
width, height = 1280, 1024
else:
return
print('%s width=%d, height=%d' % (doing, width, height))
self.w.set_fullscreen(fullscreen, width=width, height=height)
示例3: on_key_press
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import _1 [as 别名]
def on_key_press(self, symbol, modifiers):
"""Event handler for the Window.on_key_press event."""
if symbol == key.ENTER:
self.scene_manager.change_scene('GameScene')
elif symbol == key.ESCAPE:
self.window.set_exclusive_mouse(False)
return pyglet.event.EVENT_HANDLED
if symbol in (key._1, key._2, key._3):
if symbol == key._1:
self.scene_manager.save.save_slot = 1
elif symbol == key._2:
self.scene_manager.save.save_slot = 2
elif symbol == key._3:
self.scene_manager.save.save_slot = 3
self._highlight_save_slot()
示例4: __init__
# 需要导入模块: from pyglet.window import key [as 别名]
# 或者: from pyglet.window.key import _1 [as 别名]
def __init__(self, x, y):
super().__init__(PLAYER_IMAGE, x=x, y=y)
self.original_width = PLAYER_IMAGE.width
self.original_height = PLAYER_IMAGE.height
self.weapons = {
key._1: Hand(),
key._2: SnowSpread(),
key._3: RocketPropelledSnowball(),
}
self.weapon = self.weapons[key._1]
self.firing = False