本文整理汇总了Python中block.Block.turnCounter方法的典型用法代码示例。如果您正苦于以下问题:Python Block.turnCounter方法的具体用法?Python Block.turnCounter怎么用?Python Block.turnCounter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block.Block
的用法示例。
在下文中一共展示了Block.turnCounter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import turnCounter [as 别名]
#.........这里部分代码省略.........
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] :
move_flag = False
break
if move_flag:
self.block.moveDown()
else: #merge
self.mergeBlock()
self.eraseBlock()
self.newBlock()
def moveBottom(self):
#直落方塊
while True:
# move or merge
move_flag = True
for row, col in self.block.tellDownPos():
if row >= self.row_size:
move_flag = False
break
elif self.board[row][col] :
move_flag = False
break
if move_flag:
self.block.moveDown()
else: #merge
self.mergeBlock()
self.eraseBlock()
self.newBlock()
break
def turnClockwise(self):
#順時針旋轉方塊
if self.block.block_type == 'O':
return
turn_flag = True
for row, col in self.block.tellClockwisePos():
if col < 0 or col >= self.col_size \
or row < 0 or row >= self.row_size:
turn_flag = False
break
elif self.board[row][col] :
turn_flag = False
break
if turn_flag:
self.block.turnClockwise()
def turnCounter(self):
#逆時針旋轉方塊
if self.block.block_type == 'O':
return
turn_flag = True
for row, col in self.block.tellCounterPos():
if col < 0 or col >= self.col_size \
or row < 0 or row >= self.row_size:
turn_flag = False
break
elif self.board[row][col] :
turn_flag = False
break
if turn_flag:
self.block.turnCounter()