本文整理匯總了Python中Engine.Engine.send方法的典型用法代碼示例。如果您正苦於以下問題:Python Engine.send方法的具體用法?Python Engine.send怎麽用?Python Engine.send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Engine.Engine
的用法示例。
在下文中一共展示了Engine.send方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from Engine import Engine [as 別名]
# 或者: from Engine.Engine import send [as 別名]
class Program:
"""
General program template
- init function for program component initialization
- main loop
* check events -> handle (event)
* update
"""
def __init__(self):
"""
init function
"""
self.interface = Interface()
self.engine = Engine()
self.run()
def run(self):
"""
main loop
"""
while True:
self.check_events()
self.update()
def check_events(self):
"""
pygame event handling (edit this for more events)
"""
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
mousex, mousey = event.pos
response = self.interface.click(mousex,mousey)
self.handle(response)
def handle(self,response):
"""
handle responses to events
"""
self.engine.send(response)
def update(self):
"""
update state of program components
"""
self.engine.update()
self.interface.update(self.engine.get_updates())