← Каталог
Python — Space Invaders — Этап 0 — минимальный запускаемый код
Фрагмент из «Python — Space Invaders»: Этап 0 — минимальный запускаемый код.
import sys
import pygame
pygame.init()
WIDTH, HEIGHT = 640, 720
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Space Invaders — этап 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((8, 10, 24))
pygame.display.flip()
clock.tick(60)
pygame.quit()
sys.exit() import sys
import pygame
pygame.init()
WIDTH, HEIGHT = 640, 720
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Space Invaders — этап 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((8, 10, 24))
pygame.display.flip()
clock.tick(60)
pygame.quit()
sys.exit()