本文整理汇总了Python中block.Block.tellRightPos方法的典型用法代码示例。如果您正苦于以下问题:Python Block.tellRightPos方法的具体用法?Python Block.tellRightPos怎么用?Python Block.tellRightPos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block.Block
的用法示例。
在下文中一共展示了Block.tellRightPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import tellRightPos [as 别名]
#.........这里部分代码省略.........
#self.eraseBlock()
#self.newBlock()
def eraseBlock(self):
#消方塊
row_set = set()
for r, _ in self.block.tellAllPos():
row_set.add(r)
need_erased_row = []
for rs in row_set:
count = 0
for i in self.board[rs]:
if i : count+=1
if count == self.col_size: need_erased_row.append(rs)
row_num = len(need_erased_row)
if row_num:
self.draw()
sleep(0.4)
need_erased_row.sort()
need_erased_row.reverse()
for n in need_erased_row:
self.board.pop(n)
for _ in range(row_num):
self.board.insert(0, [0]*self.col_size)
self.score += row_num
def moveRight(self):
#右移方塊
move_flag = True
for row, col in self.block.tellRightPos():
if col >= self.col_size :
move_flag = False
break
elif self.board[row][col] :
move_flag = False
break
if move_flag:
self.block.moveRight()
def moveLeft(self):
#左移方塊
move_flag = True
for row, col in self.block.tellLeftPos():
if col < 0 :
move_flag = False
break
elif self.board[row][col] :
move_flag = False
break
if move_flag:
self.block.moveLeft()
def moveDown(self):
#下移方塊
move_flag = True
for row, col in self.block.tellDownPos():
if row >= self.row_size:
move_flag = False
break
elif self.board[row][col] :