import pygame
import random
# 定义方块的形状
shapes = [
[[1, 1, 1, 1]],
[[1, 1], [1, 1]],
[[0, 1, 1], [1, 1, 0]],
[[1, 1, 0], [0, 1, 1]],
[[1, 0, 0], [1, 1, 1]],
[[0, 0, 1], [1, 1, 1]],
[[1, 1, 1], [0, 1, 0]],
]
# 定义方块的颜色
colors = [
(255, 0, 0),
(0, 255, 0),
(0, 0, 255),
(255, 255, 0),
(255, 0, 255),
(0, 255, 255),
(255, 255, 255),
]
class Block:
def __init__(self, shape, color):
self.shape = shape
self.color = color
self.x = 4
self.y = 0
def rotate(self):
self.shape = [[self.shape[y][x] for y in range(len(self.shape))] for x in range(len(self.shape[0])-1, -1, -1)]
def mo