Python:
import pygame
pygame.init()
display_w = 800
display_h = 600
display = pygame.display.set_mode((display_w, display_h))
pers_width = 60
pers_height = 100
def rect(offset, height):
pers_0_x = display_w // offset
pers_0_y = display_h - height - pers_height
pers_1_x = display_w // offset
pers_1_y = display_h - height + pers_height
rect(4, [100, 600])
def rect(offset, height):
pers_2_x = display_w - offset
pers_2_y = display_h - height - pers_height
pers_3_x = display_w - offset
pers_3_y = display_h - height + pers_height
rect(260, [100, 600])
def rungame():
game = True
while game:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
display.fill((255, 255, 255))
pygame.draw.rect(display, (251,186,0), (pers_0_x, pers_0_y, pers_width, pers_height))
pygame.draw.rect(display, (168,91,56), (pers_1_x, pers_1_y, pers_width, pers_height))
pygame.draw.rect(display, (34,253,48), (pers_2_x, pers_2_y, pers_width, pers_height))
pygame.draw.rect(display, (11,28,189), (pers_3_x, pers_3_y, pers_width, pers_height))
pygame.display.update()
rungame()
Код:
Traceback (most recent call last):
File "D:\Python\Game on Python\Персонаж1.py", line 21, in <module>
rect(4, [100, 600])
File "D:\Python\Game on Python\Персонаж1.py", line 18, in rect
pers_0_y = display_h - height - pers_height
TypeError: unsupported operand type(s) for -: 'int' and 'list'
Как исправить подобную ошибку на примере вот этого кода? Если знаете, помогите пожалуйста.