Здравствуйте, не могу понять в чём проблема?!Выдаёт ошибку TypeError: rect argument is invalid!
Python:
import pygame
SIZE_BLOCK = 20
frame_color = (0, 255, 204)
white = (255, 255, 255)
BLUE = (204, 255, 255)
HEADER_COLOR = (0, 204, 153)
SNAKE_COLOR = (0, 102, 0)
COUNT_BLOCKS = 20
HEADER_MARGIN = 70
MARGIN = 1
size = [SIZE_BLOCK * COUNT_BLOCKS + 2 * SIZE_BLOCK + MARGIN * COUNT_BLOCKS,
SIZE_BLOCK * COUNT_BLOCKS + 2 * SIZE_BLOCK + MARGIN * COUNT_BLOCKS + HEADER_MARGIN]
print(size)
screen = pygame.display.set_mode(size)
pygame.display.set_caption('Змейка')
class SnakeBlock:
def __init__(self, x, y):
self.x = x
self.y = y
def draw_block(color, row, column):
pygame.draw.rect(screen, color, [SIZE_BLOCK + column * SIZE_BLOCK + MARGIN * (column + 1),
HEADER_MARGIN + SIZE_BLOCK + row * SIZE_BLOCK + MARGIN * (row + 1),
SIZE_BLOCK])
snake_block = [SnakeBlock(9, 9)]
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
print('Exit')
pygame.quit()
screen.fill(frame_color)
pygame.draw.rect(screen, HEADER_COLOR, [0, 0, size[0], HEADER_MARGIN])
for row in range(COUNT_BLOCKS):
for column in range(COUNT_BLOCKS):
if (row + column) % 2 == 0:
color = BLUE
else:
color = white
draw_block(color, row, column)
for block in snake_block():
x, y = block
draw_block(SNAKE_COLOR, block.x, block.y)
pygame.display.flip()