當我使用箭頭鍵時,我的精靈不移動?我看了我的代碼,我不能爲我的生活工作出什麼問題呢?任何幫助將大量提前預先感謝!!:D在Pygame中,我無法讓我的精靈移動?這是我的代碼嗎?
bif="cloud.jpg"
mif="reddwarf.png"
import pygame,sys
from pygame.locals import *
pygame.init()
DISPLAYSURF=screen=pygame.display.set_mode((813,555),32,0)
background=pygame.image.load(bif).convert()
mouse_c=pygame.image.load(mif).convert_alpha()
x,y=0,0
movex, movey=0,0
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type ==KEYDOWN:
if event.key==K_LEFT:
movex=-1
elif event.key==KEY_RIGHT:
movex=+1
elif event.key==K_UP:
movey=-1
elif event.key==K_DOWN:
movey=+1
if event.type==KEYUP:
if event.key==K_LEFT:
movex=0
elif event.key==KEY_RIGHT:
movex=0
elif event.key==K_UP:
movey=0
elif event.key==K_DOWN:
movey=0
x+=movex
y+=movey
screen.blit(background,(0,0))
screen.blit(mouse_c,(x,y))
pygame.display.update()
'IndentationError'? – That1Guy