デフォルトの Python IDLE と Pygame を使用してゲームを作成しています。簡単な猫のアニメーションを作成していますが、モジュールを実行しようとすると問題が発生します。黒い画面が表示され、見出しには「アニメーションが応答しません」とだけ表示されます。以下に、このアニメーションに使用されるコードを示します。助けてくれてありがとう!ありがとう、編集したばかりですが、見栄えが良くなりましたか?
import pygame, sys
from pygame.locals import *
pygame.init()
FPS = 30
fpsClock = pygame.time.Clock()
# set up the window
DISPLAYSURF = pygame.display.set_mode((400, 300), 0, 32)
pygame.display.set_caption('Animation')
WHITE = (255, 255, 255)
catImg = pygame.image.load('cat.png')
catx = 10
caty = 10
direction = 'right'
while True: # the main game loop
DISPLAYSURF.fill(WHITE)
if direction == 'right':
catx += 5
if catx == 280:
direction = 'down'
elif direction == 'down':
caty += 5
if caty == 220:
direction = 'left'
elif direction == 'left':
catx -= 5
if caty == 10:
direction = 'up'
elif direction == 'up':
caty -= 5
if caty == 10:
direction = 'right'
DISPLAYSURF.blit(catImg, (catx, caty))
for event in pygame.eventget():
if event.type == QUIT:
pygame.exit()
sys.exit()
pygame.display.update()
fpsClock.tick(FPS)