Skip to content

Instantly share code, notes, and snippets.

@LevBravE
Created April 20, 2020 20:59
Show Gist options
  • Save LevBravE/19ad8081092a8fc11a97d6897d3ee7fe to your computer and use it in GitHub Desktop.
Save LevBravE/19ad8081092a8fc11a97d6897d3ee7fe to your computer and use it in GitHub Desktop.
import pygame
size = width, height = 301, 301
screen = pygame.display.set_mode(size)
clock = pygame.time.Clock()
running = True
x_pos = 0
v = 20 # пикселей в секунду
fps = 60
while running:
# внутри игрового цикл еще один цикл
# приема и обработки сообщений
for event in pygame.event.get():
# при закрытии окна
if event.type == pygame.QUIT:
running = False
# отрисовка и изменение свойств объектов
# ...
screen.fill((0, 0, 0))
pygame.draw.circle(screen, (255, 0, 0), (int(x_pos), 200), 20)
x_pos += v / fps
clock.tick(fps)
# обновление экрана
pygame.display.flip()
pygame.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment