import pygame
import random

from pygame.examples.cursors import image

image = pygame.image.load("rocket.png")
pygame.init()
clock=pygame.time.Clock()
x = 50
y = 50
x1 = 1000
y1 = 0
x2 = 0
y2 = 600


sc = pygame.display.set_mode((1000, 600))
pygame.display.set_caption("MyGame")

go =True
while go:
    player = pygame.Rect(x, y, 67, 67)
    vrag = pygame.Rect(x1, y1, 100, 100)
    sc.fill((255, 100, 50))
    pygame.draw.rect(sc,(0, 0, 0),player)
    pygame.draw.rect(sc,(50, 50, 50), vrag)
    pygame.draw.rect(sc, (245, 190, 0), (x1+5, y1, 15, 20))
    pygame.draw.rect(sc, (255, 200, 0), (x1 + 25, y1+5, 25, 13))
    pygame.draw.rect(sc, (235, 180, 0), (x1 + 60, y1 + 30, 30, 15))
    if player.colliderect(vrag):
        print("Вы проиграли")
        go=False
    if x1==-100:
        x1= 1000
        y1= random.randint(0, 500)
    x1-=20
    if y2==-100:
        x2= 1000
        y2= random.randint(0, 500)
    x2-=20



    Keys = pygame.key.get_pressed()
    if Keys[pygame.K_RIGHT] and x<=933:
        x +=10
    Keys = pygame.key.get_pressed()
    if Keys[pygame.K_LEFT] and x>=0:
        x -=10
    Keys = pygame.key.get_pressed()
    if Keys[pygame.K_UP] and y>=0:
        y -= 10
    Keys = pygame.key.get_pressed()
    if Keys[pygame.K_DOWN] and y<=533:
        y += 10
    pygame.display.update()
    clock.tick(30)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            go = False
