Почему возникает ошибка 'tuple' object is not callable (line33), pygame
import pygame
pygame.init()
RES=800
SIZE=600
# размер дисплея
display = pygame.display.set_mode((RES , SIZE))
# название игры
pygame.display.set_caption("test game")
# иконка игры
icon = pygame.image.load("icon.png")
pygame.display.set_icon(icon)
# размер персонажа
usr_shirina = 60
usr_visota = 100
usr_x = RES // 3
usr_y = SIZE - usr_visota - 100
# анимация прыжка
anim_jump = False
jump_counter = 30
# кактусы
cactus_height = 70
cactus_widht = 20
cactus_x = RES - 50
cactus_y = SIZE - RES - 100
def cactus_draw():
global cactus_x , cactus_y , cactus_height , cactus_widht
if cactus_x >= -cactus_widht:
pygame.draw.rect(display,(162, 207, 10) (cactus_y , cactus_x, cactus_widht , cactus_height))
cactus_x -= 4
else:
cactus_x = RES - 50
# время
clock = pygame.time.Clock()
#игровой цикл
def run_game():
game = True
# бесконечный цикл
while run_game:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
land = pygame.image.load("land1.png")
# клавиши
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
anim_jump = True
# прыжок
def jump():
global usr_y, anim_jump, jump_counter
if jump_counter >= -30:
usr_y -= jump_counter / 2.5
jump_counter -= 1
else:
jump_counter = 30
anim_jump = False
if anim_jump:
jump()
# цвет дисплея
display.blit(land , (0,0))
cactus_draw()
# цвет персонажа
pygame.draw.rect(display, (166,225,40), (usr_x , usr_y , usr_visota , usr_shirina))
# чтобы цвет отображался
pygame.display.update()
# анимация
clock.tick(60)
run_game()
Ответы (1 шт):
Автор решения: Roman Konoval
→ Ссылка
В этом месте пропущена запятая:
pygame.draw.rect(display,(162, 207, 10) (cactus_y , cactus_x, cactus_widht , cactus_height))
Должно быть:
pygame.draw.rect(display,(162, 207, 10), (cactus_y , cactus_x, cactus_widht , cactus_height))