私はミニRPGのものです。画像を変更するようにコードを作成しようとしましたが、コードが機能しません。私は多くの記事を見てきましたが、私の場合の解決策は見つかりませんでした。特定の分野で何か問題があったのですか、まったく間違った角度でコードを開始しましたか?ヘルプは非常に高く評価されます。パイガームの画像が変わります
import pygame
pygame.init()
width = 800
height = 600
black = (0, 0, 0)
white = (255, 255, 255)
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
gameDisplay = pygame.display.set_mode((width, height))
pygame.display.set_caption('8Bit Adventure Time!')
clock = pygame.time.Clock()
finnImg = [pygame.image.load('AdvManRight.png'), pygame.image.load('AdvManLeft.png')]
finnImg_current = finnImg[0]
finnwidth = 115
finnheight = 201
def Finn(x, y):
gameDisplay.blit(finnImg_current, (x, y))
def game_loop():
x = ((width/2) - (finnwidth/2))
y = ((height/2) - (finnheight/2))
gameExit = False
while not gameExit:
x_change = 0
y_change = 0
gameDisplay.fill(white)
Finn(x,y)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
finnImg_current = finnImg[0]
pygame.display.update() #the image is supposed to change here, but nothing happens...
x_change = -40
if event.key == pygame.K_RIGHT:
finnImg_current = finnImg[1]
pygame.display.update() #the image is supposed to change here, but nothing happens...
x_change = 40
if event.key == pygame.K_UP:
y_change = -40
if event.key == pygame.K_DOWN:
y_change = 40
x += x_change
y += y_change
pygame.display.update()
clock.tick(60)
game_loop()
pygame.quit()
quit()
ありがとうございました!私はその情報を読んだ後に働いた。 –