def keyPressEvent(self, event):
if not self.isStarted or self.isPaused or self.curPiece.shape() == NoShape:
super(TetrixBoard, self).keyPressEvent(event)
return
key = event.key()
if key == Qt.Key_Left:
self.tryMove(self.curPiece, self.curX - 1, self.curY)
elif key == Qt.Key_Right:
self.tryMove(self.curPiece, self.curX + 1, self.curY)
elif key == Qt.Key_Down:
self.tryMove(self.curPiece.rotatedRight(), self.curX, self.curY)
elif key == Qt.Key_Up:
self.tryMove(self.curPiece.rotatedLeft(), self.curX, self.curY)
elif key == Qt.Key_Space:
self.dropDown()
elif key == Qt.Key_D:
self.oneLineDown()
else:
super(TetrixBoard, self).keyPressEvent(event)
评论列表
文章目录