本文整理汇总了Python中GameLogic.gameLogic方法的典型用法代码示例。如果您正苦于以下问题:Python GameLogic.gameLogic方法的具体用法?Python GameLogic.gameLogic怎么用?Python GameLogic.gameLogic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameLogic
的用法示例。
在下文中一共展示了GameLogic.gameLogic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mainLoop
# 需要导入模块: import GameLogic [as 别名]
# 或者: from GameLogic import gameLogic [as 别名]
def mainLoop():
pygame.init()
init()
initHUD()
clock = pygame.time.Clock()
Indicator.HUDs["computer"].changeText(0)
Indicator.HUDs["player"].changeText(0)
bg = pygame.Surface(conf.resolution)
bg.fill(pygame.Color(conf.backGroundColor))
gameField = pygame.Surface((conf.resolution[0] - conf.gameFieldOffset[0], conf.resolution[1] - conf.gameFieldOffset[1]))
gameField.fill(pygame.Color(Level.enumColor.fieldBackgroundColor))
lvl = Level.Level(gameField, conf.N)
logic = GameLogic.gameLogic(lvl)
machine = Player.MachinePlayer("base", lvl)
while True:
# event block
for e in pygame.event.get():
if e.type == pygame.QUIT:
sys.exit(0)
if e.type == pygame.MOUSEBUTTONDOWN:
if logic.activePlayer[0] == GameLogic.enumControlType.human:
pos = pygame.mouse.get_pos()
relativePos = (pos[0] - conf.gameFieldOffset[0], pos[1] - conf.gameFieldOffset[1])
move = lvl.transformMousePosToCells(relativePos)
logic.makeMove(move)
# update block
Indicator.HUDs["move"].changeText(*logic.getInfo())
for key in logic.state["score"]:
Indicator.HUDs[key].changeText(logic.state["score"][key])
if logic.activePlayer[0] == GameLogic.enumControlType.machine:
move = machine.makeMove(logic.state["moves"])
logic.makeMove(move)
if logic.exitState[0]:
if logic.exitState[1] == GameLogic.enumPlayers.player2[1]:
machine.flushHistory()
machine.close()
return logic.exitState[1]
# show block
conf.screen.blit(bg, (0, 0))
conf.screen.blit(gameField, conf.gameFieldOffset)
lvl.drawLevel()
for hud in Indicator.HUDs.values():
hud.show()
pygame.display.update()
clock.tick(100)