помогите пожалуйста я просто недавно программирую и не могу понять что за ошибка
вот код:
вот код:
Python:
import pygame
import time
pygame.init()
display_width = 800
display_height = 600
display = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption("RUN!")
icon = pygame.image.load('icon.png')
pygame.display.set_icon(icon)
class Rock:
def __init__(self, x, y, width, height, speed):
self.x = x
self.y = y
self.width = width
self.height = height
self.speed = speed
def move(self):
if self.x >= -self.width:
pygame.draw.rect(display, (99, 108, 115), (self.x, self.y, self.width, self.height))
self.x -= self.speed
else:
self.x = display_width - 50
usr_width = 60
usr_height = 100
usr_x = display_width // 3
usr_y = display_height - usr_height - 100
rock_w = 20
rock_h = 70
rock_x = display_width - 50
rock_y = display_height - rock_h - 100
clock = pygame.time.Clock()
make_jump = False
jump_counter = 30
def gamerun():
global make_jump
game = True
rock_arr = []
create_rock_arr(rock_arr)
while game:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
keys = pygame.key.get_pressed()
if keys[pygame.K_SPACE]:
make_jump = True
if make_jump:
jump()
time.sleep(0.01)
display.fill((255, 255, 255))
draw_array(rock_arr)
pygame.draw.rect(display, (41, 34, 61), (usr_x, usr_y, usr_width, usr_height))
pygame.display.update()
def jump():
global usr_y, jump_counter, make_jump
if jump_counter >= -30:
usr_y -= jump_counter / 2
jump_counter -= 1
else:
jump_counter = 30
make_jump = False
def create_rock_arr(array):
array.append(Rock(display_width - 50, display_height - 170, 20, 70, 4)
array.append(Rock(display_width - 300, display_height - 150, 20, 50, 4)
array.append(Rock(display_width - 600, display_height - 180, 20, 80, 4)
def draw_array(array):
for rock in array:
rock.move
gamerun()