本文整理汇总了Python中cell.Cell.rect方法的典型用法代码示例。如果您正苦于以下问题:Python Cell.rect方法的具体用法?Python Cell.rect怎么用?Python Cell.rect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cell.Cell
的用法示例。
在下文中一共展示了Cell.rect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
# 需要导入模块: from cell import Cell [as 别名]
# 或者: from cell.Cell import rect [as 别名]
def reset(self):
"""
Reset tiles and spawn mines at new locations
"""
# set cells up on board
for i in xrange(self.rows):
for j in xrange(self.cols):
cell = Cell(i, j, self.screen)
# cell.revealed = True
ypos = self.board_padding + (self.cell_size * i) + (self.cell_margin * i) + self.header_height
xpos = self.board_padding + (self.cell_size * j) + (self.cell_margin * j)
rect = Rect(xpos, ypos, self.cell_size, self.cell_size)
cell.rect = rect
self.cells[i][j] = cell
# remove previous mine locations
del self.mine_locations[:]
# add new random mines
for m in xrange(self.mines):
rand_row = random.randint(0, self.rows-1)
rand_col = random.randint(0, self.cols-1)
random_mine = (rand_row, rand_col)
if random_mine not in self.mine_locations:
random_mine = (rand_row, rand_col)
self.cells[rand_row][rand_col].is_mine = True
self.mine_locations.append(random_mine)
# reset cell state and calculate new neighbor values for each cell
for i in xrange(self.rows):
for j in xrange(self.cols):
cell = self.cells[i][j]
neighbors = self.get_neighbor_cells(i, j)
for n in neighbors:
if n.is_mine: cell.neighbors += 1