import pygame
import os
import random

from pygame.examples.go_over_there import screen, running
from pygame.examples.moveit import HEIGHT

pygame.init()

WIDTH = 1800
HEIGHT = 840
FPS = 60

WHITE = (255,255,255)
BLACK = (0,0,0)
RED = (255,0,0)
GREEN = (0,255,0)
BLUE = (0,0,255)
DARK_VIOLETT = (51,15,98)
PTNK = (255,192,203)
YELLOW = (255,255,0)
PURPLE = (128,0,128)



class Player(pygame.sprite.Sprite):
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image = pygame.Surface((30,80))
        self.image.fill(GREEN)
        self.rect = self.image.get_rect()
        self.rect.x = WIDTH/2
        self.rect.y = HEIGHT-10
        self.speedx = 1
        self.score = 0
        def update(self):
            keystate = pygame.key.get_pressed()
            if keystate[pygame.K_LEFT]:
                self.speedx-=10
            if keystate[pygame.K_RIGHT]:
                self.speedx+=10
            if keystate[pygame.K_DOWN]:
                self.speedx-=10
            if keystate[pygame.K_UP]:
                self.speedx+=10
            self.rect.x = self.speedx
            if self.rect.right > WIDTH:
                self.rect.right = WIDTH
            if self.rect.left < 0:
                self.rect.left = 0
            if self.rect.up > HEIGHT/2:
                self.rect.up = HEIGHT/2
            if self.rect.down < 0:
                self.rect.down = 0


pygame.mixer.init()
screen = pygame.display.set_mode((WIDTH,HEIGHT))
screen = pygame.display.set_caption("Моя Игра")
clock = pygame.time.Clock()
all_sprites = pygame.sprite.Group()
player = Player()
all_sprites.add(player)

running = True
while running:
    clock.tick(FPS)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    all_sprites.update(DARK_VIOLETT)
    all_sprites.draw(screen)
    pygame.display.flip()

pygame.quit()