Python pygame sur = pygame.Surface(288, 512) ValueError: size needs to be (number width, number height)

Сначала была ошибка с Rect, помогли вроде решил, теперь проблема с Surface. Ошибка:

    sur = pygame.Surface(288, 512)
ValueError: size needs to be (number width, number height)

Мой код:

import pygame
pygame.init()

WIDTH, HEIGHT = 288, 512
FPS = 60

window = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()

imgFON = pygame.image.load('images/fon.png')
imgBIRD = pygame.image.load('images/bird.png')
imgPB = pygame.image.load('images/PB.png')
imgPT = pygame.image.load('images/PT.png')
py, sy, ay = HEIGHT // 2, 0, 0
player = pygame.Rect(HEIGHT // 3, py, 50, 50)

state = 'start'
timer = 10
sur = pygame.Surface(288, 512)
pipes = []
bges = []

bges.append(sur)

play = True
while play:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            play = False

    press = pygame.mouse.get_pressed()
    keys = pygame.key.get_pressed()
    click = press[0] or keys[pygame.K_SPACE]

    if timer > 0:
        timer -= 1

    for fon in reversed(bges):
        imgFON.x -= 1

    if imgFON.right < 0:
        bges.remove(imgFON)

    for i in range(len(pipes)-1, -1, -1):
        pipe = pipes[i]
        pipe.x -= 3

        if pipe.right < 0:
            pipes.remove(pipe)


    if state == 'start':
        if click and timer == 0 and len(pipes) == 0:
            state = 'play'

        py += (HEIGHT // 2 - py) * 0.1
        player.y = py

    elif state == 'play':
        if click:
            ay = -2
        else:
            ay = 0

        py += sy
        sy = (sy + ay + 1) * 0.98
        player.y = py 

        if len(pipes) == 0 or pipes[len(pipes)-1].x < WIDTH - 200:
            pipes.append(pygame.Rect(WIDTH, 0, 52, 200))
            pipes.append(pygame.Rect(WIDTH, 400, 52, 200))

        if player.top < 0 or player.bottom > HEIGHT:
            state = 'fall'

        for pipe in pipes:
            if player.colliderect(pipe):
                state = 'fall'

    elif state == 'fall':
        sy, ay = 0, 0
        state = 'start'
        timer = 60
    else:
        pass



    window.fill(pygame.Color('black'))
    for fon in bges:
        window.blit(imgFON, fon)
    for pipe in pipes:
        if pipe.y == 0:
            rect = imgPB.get_rect(bottomleft = pipe.bottomleft)
            window.blit(imgPB, rect)
        else:
            rect = imgPT.get_rect(topleft = pipe.topleft)
            window.blit(imgPT, rect)

    window.blit(imgBIRD, player)

    pygame.display.update()
    clock.tick(FPS)

pygame.quit()

Ответы (0 шт):