为什么,有了这个代码,船不会改变它的位置
import pygame
pygame.init()
sc = pygame.display.set_mode((1200, 1200))
clock = pygame.time.Clock()
FPS = 60
x = 600
y = 600
K = pygame
def SpaceShip(xShip, yShip):
ship_surf = pygame.image.load('spaceShip.png')
ship_rect = ship_surf.get_rect(bottomright=(xShip - 32, yShip - 32))
ship_surf = pygame.transform.scale(ship_surf, (100,100))
sc.blit(ship_surf, ship_rect)
pygame.display.update()
while True:
sc.fill((0,0,0))
SpaceShip(x, y)
for i in pygame.event.get():
if i.type == pygame.QUIT:
exit()
keys = pygame.key.get_pressed()
if keys == K.K_LEFT:
x -= 3
elif keys == K.K_RIGHT:
x += 3
pygame.display.update()
clock.tick(FPS)
您没有正确检查按钮点击,应该是这样的: