ошибка collision помогите исправить

error screenshot (ship228.png) background image(228.png

import pygame
import random as rnd
from random import randint, randrange

pygame.init()
pygame.display.set_caption('Final Project')
WIDTH, HEIGHT = 800, 400
screen = pygame.display.set_mode((WIDTH, HEIGHT))
bg_img = pygame.image.load('228.jpg')

clock = pygame.time.Clock()



ship = pygame.sprite.Sprite()
ship_w = 128
ship_h = 128
ship_speed = 15
ship.rect = pygame.Rect(WIDTH - 800 - ship_w // 2, HEIGHT - ship_h - 200, ship_w, ship_h)

ship_img = pygame.image.load('ship228.png')




block_x = WIDTH - 50
block_y = HEIGHT // 2
block_speed = 10
asteroidslist = list()





run = True
for i in range(5):
    asteroids = pygame.Rect(randint(1000, 2000), randint(0, HEIGHT - 50), 25, 25)
    asteroidslist.append(asteroids)


while run:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            run = False
    screen.blit(bg_img, (0, 0))
    key = pygame.key.get_pressed()
    if key[pygame.K_w] and ship.y > 0:
        ship.y -= ship_speed
    if key[pygame.K_s] and ship.y < HEIGHT - ship_h:
        ship.y += ship_speed

    for x in (asteroidslist):
        pygame.draw.rect(screen, 'red', x)
        x.x -= 10
        if x.x < 0 - 25:
            x.x, x.y = (rnd.randint(1000, 2000)), (rnd.randint(0, HEIGHT - 50))
        if pygame.sprite.collide_rect(ship, asteroids):
            pygame.QUIT




    screen.blit(ship_img, ship)
    clock.tick(60)


    pygame.display.update()

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