

import pygame
import random
import os
pygame.init()
sc = pygame.display.set_mode((1200, 890))
clock=pygame.time.Clock()
game_fold = os.path.dirname(__file__)
png_fold = os.path.join(game_fold, "png")
korablik = pygame.image.load(os.path.join(png_fold, "караблик.bmp"))

class Enemy:
    def __init__(self):
        self.x = random.randint(100, 110)
        self.y = random.randint(100, 110)
        self.size= 50
        self.speed = random.randint(3, 7)
        self.dir = random.randint(1, 4)
        self.timer = 0

    def move(self):
        self.timer += 1
        if self.timer > 30:
            self.dir = random.randint(1, 4)
            self.timer = 0

        if self.dir == 1: self.y -= self.speed
        if self.dir == 2: self.x -= self.speed
        if self.dir == 3: self.y += self.speed
        if self.dir == 4: self.x += self.speed


    def draw(self):
        return pygame.draw.rect(sc, (210, 210, 210), [self.x, self.y, self.size, self.size])

bullets = pygame.sprite.Group()
enemies = [Enemy() for i in range(1000)]
x, y = 800,800
go = True
while go:
    sc.fill((255, 150, 0))
    plaer_rect = pygame.Rect(x, y, 50, 50)
    pygame.draw.rect(sc, (0, 150, 255), plaer_rect)

    for e in enemies:
        e.move()
        enemy_rect = e.draw()

        if plaer_rect.colliderect(enemy_rect):
            print("Командир, у нас пробойна!")
            go = False

    Keys = pygame.key.get_pressed()
    if Keys[pygame.K_LEFT]: x -= 20
    if Keys[pygame.K_RIGHT]: x += 20
    if Keys[pygame.K_UP]: y -= 20
    if Keys[pygame.K_DOWN]: y += 20
    #просчёт стрельбы вверх. создаются классы (не функцей для игрока, потому что класс игрока не нашёл. нет рисовки пуль.
    if Keys[pygame.K_SPACE]:
        b = BulletRight()
        bullets.add(b)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            go = False

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


class Bullet:
    def __init__(self, x, y):
        self.x = x + 80
        self.y = y + 25
        self.size = 10
        self.speed = 15
        self.active = True

    def move(self):
        self.x += self.speed

    def draw(self):
        if self.active:
            return pygame.draw.rect(sc, (255, 255, 0), self.x, self.y, self.size, 5)

    def check_collision (self, enemy):
        enemy.rect = pygame.Rect(enemy.x, enemy.y, 40, 90)
        bullet_rect = pygame.Rect(self.x, self.y, self.size, 5)
        return bullet_rect.colliderect(enemy_rect)



def get_rect(self):
    return pygame.Rect(self.x, self.y, 40, 90)
bullets = []
collets = 



for bullet in bullets

pygame.quit()