我一直在研究这个,我不知道为什么它不能正常移动。只有当我按 D 代码时它才会向左移动。请帮我
bif = "bif.jpg"
mif = "games.png"
import pygame, sys
from pygame.locals import *
pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
background=pygame.image.load(bif).convert()
cursor=pygame.image.load(mif).convert_alpha()
x,y=4,4
movex,movey=0,0
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
if event.type == KEYDOWN:
if event.key==K_a:
movex=-3
elif event.key==K_d:
movex=+3
elif event.key==K_s:
movey=+3
elif event.key==K_w:
movey= -3
if event.type == KEYUP:
if event.key==K_a:
movex=0
elif event.key==K_w:
movex=0
elif event.key==K_s:
movey=0
elif event.key==K_d:
movey= 0
x = x + movex
y = y+movex
screen.blit(background, (0,0))
screen.blit(cursor, (x,y))
pygame.display.update()
有可能是硬件错误吗?