pip install pygame python import pygame pygame.init() screen_width = 800 screen_height = 600 screen = pygame.display.set_mode((screen_width, screen_height)) block_size = 50 block_x = 0 block_y = screen_height // 2 - block_size // 2 block_speed = 5 running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False screen.fill((0, 0, 0)) block_x += block_speed if block_x > screen_width: block_x = -block_size pygame.draw.rect(screen, (255, 255, 255), (block_x, block_y, block_size, block_size)) pygame.display.flip() pygame.quit()


上一篇:
下一篇:
切换中文