本文整理汇总了Python中Matrix.put方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.put方法的具体用法?Python Matrix.put怎么用?Python Matrix.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Matrix
的用法示例。
在下文中一共展示了Matrix.put方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import put [as 别名]
def save(self, name):
xlow = min(x for x, y in self.jobs.board.blocks)
xhigh = max(x for x, y in self.jobs.board.blocks)
ylow = min(y for x, y in self.jobs.board.blocks)
yhigh = max(y for x, y in self.jobs.board.blocks)
matrix = [
[(x, y) in self.jobs.board.blocks for x in xrange(xlow, xhigh+1)]
for y in xrange(ylow, yhigh+1)
]
Log.log("Created new tetromino, displaying below")
Matrix.put(matrix)
Save.saveTetromino(self.color, name, matrix)
Shared.tetrominos = Load.loadTetrominos()
return True
示例2: mainGame
# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import put [as 别名]
def mainGame(self):
if not self.jobs.interface.jobs.board.update_required and not hasattr(self.jobs, "window-game_over"):
## XXX: GAME OVER
board = self.jobs.interface.jobs.board
Log.log("Game over, displaying game state")
matrix = [
[(x, y) in board.blocks for x in xrange(board.blocks_width)]
for y in xrange(board.blocks_height)
]
Matrix.put(matrix, f="_")
if ((len(self.highscores) < HIGHSCORES or any(board.score > score["score"] for score in self.highscores)) and
not Shared.options.get("uber_tetromino") and not Shared.options.get("flip_tetromino")
):
self.addJob("name_inputbox", Jobs.InputBox(self, "New Highscore!\nName: "))
self.running = self.getName
else:
self.addJob("window-game_over", Jobs.Notification(self, "window-game_over", "Game Over"))
self.addJob("endtimer", Jobs.TimedExecution(self, self.quitGame, seconds=3, anykey=True))
示例3: handleWinner
# 需要导入模块: import Matrix [as 别名]
# 或者: from Matrix import put [as 别名]
def handleWinner(*interfaces):
for interface in interfaces:
if not interface.jobs.board.update_required and not hasattr(self.jobs, "window_game_over"):
## XXX: LOSER
board = interface.jobs.board
Log.log("Game over, displaying game state")
matrix = [
[(x, y) in board.blocks for x in xrange(board.blocks_width)]
for y in xrange(board.blocks_height)
]
Matrix.put(matrix, f="_")
self.addJob("window_game_over",
Jobs.TextBox(self, "Yuo An Losar", font={"name": "orbitron-bold", "size": 30, "bold": True},
textfit=True, onmouseclick=lambda: game.removeJob("window_game_over"),
colors=ERRORBOX_COLORSCHEME, background=True, border=True,
padding=6,
)
)
self.jobs.window_game_over.x = interface.x + interface.width//2
self.jobs.window_game_over.y = interface.y + interface.height//2 - self.jobs.window_game_over.height//2
if sum(int(iface.jobs.board.update_required) for iface in interfaces) == 1 and not hasattr(self.jobs, "endtimer"):
## XXX: WINNER
interface = [iface for iface in interfaces if iface.jobs.board.update_required][0]
self.addJob("window_win",
Jobs.TextBox(self, "Yuo An Winrar", font={"name": "orbitron-bold", "size": 30, "bold": True},
textfit=True, onmouseclick=lambda: game.removeJob("window_win"),
colors=ERRORBOX_COLORSCHEME, background=True, border=True,
padding=6,
)
)
self.jobs.window_win.x = interface.x + interface.width//2
self.jobs.window_win.y = interface.y + interface.height//2 - self.jobs.window_win.height//2
self.addJob("endtimer", Jobs.TimedExecution(self, self.quitGame, seconds=3, anykey=False, timed=True))