本文整理汇总了Python中shape.Shape.rotatedLeft方法的典型用法代码示例。如果您正苦于以下问题:Python Shape.rotatedLeft方法的具体用法?Python Shape.rotatedLeft怎么用?Python Shape.rotatedLeft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shape.Shape
的用法示例。
在下文中一共展示了Shape.rotatedLeft方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Board
# 需要导入模块: from shape import Shape [as 别名]
# 或者: from shape.Shape import rotatedLeft [as 别名]
#.........这里部分代码省略.........
boardTop = rect.bottom() - Board.BoardHeight * self.getSelHeight()
for i in range(Board.BoardHeight):
for j in range(Board.BoardWidth):
shape = self.getShapeAt(j, Board.BoardHeight - i - 1)
if shape != Tetrominoes.NoShape:
self.drawSquare(painter, rect.left() + j * self.getSelWidth(), boardTop + i * self.getSelHeight(), shape)
if self.curPiece.getShape() != Tetrominoes.NoShape:
for i in range(4):
x = self.curX + self.curPiece.getX(i)
y = self.curY - self.curPiece.getY(i)
self.drawSquare(painter, rect.left() + x * self.getSelWidth(), boardTop + (Board.BoardHeight - y - 1) * self.getSelHeight(), self.curPiece.getShape())
def keyPressEvent(self, event):
if not self.isStarted or self.curPiece.getShape() == Tetrominoes.NoShape:
QtGui.QWidget.keyPressEvent(self, event)
return
key = event.key()
if key == QtCore.Qt.Key_P:
self.pause()
return
if self.isPaused:
return
elif key == QtCore.Qt.Key_Left:
self.tryMove(self.curPiece, self.curX - 1, self.curY)
elif key == QtCore.Qt.Key_Right:
self.tryMove(self.curPiece, self.curX + 1, self.curY)
elif key == QtCore.Qt.Key_Down:
self.tryMove(self.curPiece.rotatedRight(), self.curX, self.curY)
elif key == QtCore.Qt.Key_Up:
self.tryMove(self.curPiece.rotatedLeft(), self.curX, self.curY)
elif key == QtCore.Qt.Key_Space:
self.dropDown()
elif key == QtCore.Qt.Key_D:
self.oneLineDown()
else:
QtGui.QWidget.keyPressEvent(self, event)
def timerEvent(self, event):
if event.timerId() == self.timer.timerId():
if self.isWaitingAfterLine:
self.isWaitingAfterLine = False
self.newPiece()
else:
self.oneLineDown()
else:
QtGui.QFrame.timerEvent(self, event)
def clearBoard(self):
for i in range(Board.BoardHeight * Board.BoardWidth):
self.board.append(Tetrominoes.NoShape)
def dropDown(self):
newY = self.curY
while newY > 0:
if not self.tryMove(self.curPiece, self.curX, newY - 1):
break
newY -= 1
self.pieceDropped()
def oneLineDown(self):
if not self.tryMove(self.curPiece, self.curX, self.curY - 1):