本文整理汇总了Python中World.World.stateGame方法的典型用法代码示例。如果您正苦于以下问题:Python World.stateGame方法的具体用法?Python World.stateGame怎么用?Python World.stateGame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World.World
的用法示例。
在下文中一共展示了World.stateGame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from World import World [as 别名]
# 或者: from World.World import stateGame [as 别名]
class Controller:
def __init__(self):
self.world = World()
def events(self, event):
self.__eventExit(event)
self.__eventKey(event)
def __eventExit(self, event):
if (event.type == pygame.QUIT) or (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE):
sys.exit()
def __eventKey(self, event):
self.__eventKeyDown(event)
self.__eventKeyUp(event)
def __eventKeyDown(self, event):
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
self.world.getPlayer().toLeft()
elif event.key == pygame.K_RIGHT:
self.world.getPlayer().toRight()
elif event.key == pygame.K_DOWN:
self.world.getPlayer().toDown()
elif event.key == pygame.K_UP:
self.world.getPlayer().toUp()
elif event.key == pygame.K_SPACE:
if self.world.getPlayer().isLive():
if not self.world.getPlayer().getAtack().isAtack():
self.world.getPlayer().isAtack()
def __eventKeyUp(self, event):
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT:
self.world.getPlayer().setLeft(False)
elif event.key == pygame.K_RIGHT:
self.world.getPlayer().setRight(False)
elif event.key == pygame.K_DOWN:
self.world.getPlayer().setDown(False)
elif event.key == pygame.K_UP:
self.world.getPlayer().setUp(False)
def startTime(self):
self.world.timerStart()
def process(self):
if self.world.getState() == StateWorld.GAME:
self.world.stateGame()
if self.world.getState() == StateWorld.MEAT:
self.world.stateMeat()
if self.world.getState() == StateWorld.WIN:
self.world.stateWin()