本文整理匯總了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':