本文整理汇总了Python中keyboard.Keyboard.down方法的典型用法代码示例。如果您正苦于以下问题:Python Keyboard.down方法的具体用法?Python Keyboard.down怎么用?Python Keyboard.down使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keyboard.Keyboard
的用法示例。
在下文中一共展示了Keyboard.down方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameManager
# 需要导入模块: from keyboard import Keyboard [as 别名]
# 或者: from keyboard.Keyboard import down [as 别名]
#.........这里部分代码省略.........
# self.RECORDING = Toggle(source = self.keyboard[sf.Key.T],
# initVal = False)
self.won = False
# Start the system running
self.running = DataToggle(
source = DataOr(self.keyboard[sf.Key.ESCAPE],
DataAnd(self.keyboard[sf.Key.Q],
DataOr(self.keyboard[sf.Key.L_SYSTEM],
self.keyboard[sf.Key.R_SYSTEM]))),
initVal = True)
################################################################################
def handle_input(self):
"""Processes the list of events, sending them to their various handlers.
"""
for event in self.window.iter_events():
# If the window is ever closed, stop running.
if event.type == sf.Event.CLOSED:
self.running = False
return
# Send key events to the keyboard, intercepting certain special
# cases (that restart the game)
elif event.type == sf.Event.KEY_PRESSED:
if event.code == sf.Key.R or \
(event.code == sf.Key.SPACE and not self.players[-1].alive):
self.start_again()
continue
self.keyboard.down(event.code)
elif event.type == sf.Event.KEY_RELEASED:
self.keyboard.up(event.code)
self.keyboard.increment()
for vkb in self.virtual_keyboards:
vkb.increment()
################################################################################
def run(self):
"""Main game loop. Updates all entities then draws everything,
repeating over and over again."""
# Begin loop
while self.running:
self.handle_input()
self.update()
if self.running:
self.draw()
# if self.RECORDING:
# self.image.copy_screen(self.window)
# self.image.save_to_file("frames/"+str(self.frameNo) + ".png")
# self.frameNo += 1
self.shutdown()
################################################################################
def update(self):
"""Update the game's state."""
# Handle the menu screens
if self.state == 'game':