Код IT
← Каталог

Python — Ping Pong — Этап 0 — минимальный запускаемый код

Фрагмент из «Python — Ping Pong»: Этап 0 — минимальный запускаемый код.

python spinoffencyclopedia9-04-razrabotka-igr-praktikum-razrabotki-igr-3 embed URL статья в энциклопедии
Python main.py
import sys
import pygame

pygame.init()

SCREEN_W, SCREEN_H = 960, 540
FPS = 60

screen = pygame.display.set_mode((SCREEN_W, SCREEN_H))
pygame.display.set_caption("Ping Pong — этап 0")
clock = pygame.time.Clock()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
            running = False

    screen.fill((10, 12, 18))
    pygame.display.flip()
    dt = clock.tick(FPS) / 1000.0

pygame.quit()
sys.exit()
import sys
import pygame

pygame.init()

SCREEN_W, SCREEN_H = 960, 540
FPS = 60

screen = pygame.display.set_mode((SCREEN_W, SCREEN_H))
pygame.display.set_caption("Ping Pong — этап 0")
clock = pygame.time.Clock()

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
            running = False

    screen.fill((10, 12, 18))
    pygame.display.flip()
    dt = clock.tick(FPS) / 1000.0

pygame.quit()
sys.exit()