[Python] 纯文本查看 复制代码 import pygame
import sys
pygame.init()
pygame.display.set_caption('元神')
screen = pygame.display.set_mode((800, 600))
clock = pygame.time.Clock()
x, y = 400, 300
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.puit()
sys.exit()
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
print(keys)
x -= 10
if keys[pygame.K_DOWN]:
x += 10
if keys[pygame.K_UP]:
y -= 10
if keys[pygame.K_RIGHT]:
y += 10
screen.fill((255, 255, 255))
pygame.draw.rect(screen, (255, 155, 155), (x, y, 50, 50), 0)
clock.tick(10)
pygame.display.update()
|