import pygame
import sys
FPS = 60
W = 800 # ширина экрана
H = 800 # высота экрана
WHITE = (255, 255, 255)
BLUE = (0, 70, 225)
RIGHT = "to the right"
LEFT = "to the left"
STOP = "stop"
DOWN = "to the down"
UP = "tot the up"
sc = pygame.display.set_mode((W, H))
clock = pygame.time.Clock()
# координаты и радиус круга
x = 350
y = 250
r = 50
print(y)
motion = STOP
while 1:
for i in pygame.event.get():
if i.type == pygame.QUIT:
pygame.quit()
elif i.type == pygame.KEYDOWN:
if i.key == pygame.K_LEFT:
motion = LEFT
elif i.key == pygame.K_RIGHT:
motion = RIGHT
elif i.key == pygame.K_DOWN:
motion = DOWN
elif i.key == pygame.K_UP:
motion = UP
elif i.type == pygame.KEYUP:
if i.key in [pygame.K_LEFT,
pygame.K_RIGHT,
pygame.K_DOWN,
pygame.K_UP]:
motion = STOP
sc.fill(WHITE)
pygame.draw.circle(sc, BLUE, (x, y), r)
pygame.display.update()
if motion == LEFT:
x -= 3
elif motion == RIGHT:
x += 3
elif motion == DOWN:
y += 3
elif motion == UP:
y -= 3
elif motion == STOP:
if x > 350:
x -= 3
if x < 350:
x += 3
if y > 250:
y -= 3
if y < 250:
y += 3
clock.tick(FPS)
|