出于某种原因,这段代码在我运行时一直循环。
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
sys.exit()
x = p_pos[0]
y = p_pos[1]
if event.key == pygame.K_LEFT:
x -= 30
if event.key == pygame.K_RIGHT:
x += 30
p_pos = [x,y]