import pygame
pygame.init()
level = [
"BB BB",
"BB BB BB BB BB",
"BB BB BB",
"BB BB",
"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"
]
x = y = 0
BLACK = (0,0,0) #RGB
WHITE = (255,255,255) #RGB
BLOCKSIZE = 16 #width and height of the block
screen = pygame.display.set_mode((len(level[0])*BLOCKSIZE,len(level)*BLOCKSIZE),0,32)
screen.fill(WHITE)
for row in level: #level is your array that you have shown above in your question
for cell in row:
if cell == "B":
screen.fill(BLACK,(x,y,BLOCKSIZE,BLOCKSIZE))
x += BLOCKSIZE
y += BLOCKSIZE
x = 0
pygame.display.update()
while True:
#loop through your code
基本的に、リストの各文字をループし、そこにブロックがある場合は、対応する場所に黒い四角を描きます。
また、レベル リストには、すべての行の後にコンマを含める必要があります (リストであるため)。