使っている環境
python3.7.0
pygame1.9.4
mojave
上の環境でpygameのコードを実行しても、ブランクウィンドウが現れ、音は聞こえますが、画像は何も表示されません。
同じコードを古いmacのhigh sierraで実行すると表示されます。
python
1import pygame, sys 2from pygame.locals import * 3 4pygame.init() 5 6FPS = 30 # frames per second setting 7fpsClock = pygame.time.Clock() 8 9# set up the window 10DISPLAYSURF = pygame.display.set_mode((400, 300), 0, 32) 11pygame.display.set_caption('Animation') 12 13WHITE = (255, 255, 255) 14catImg = pygame.image.load('cat.png') 15catx = 10 16caty = 10 17direction = 'right' 18 19while True: # the main game loop 20 DISPLAYSURF.fill(WHITE) 21 22 if direction == 'right': 23 catx += 5 24 if catx == 280: 25 direction = 'down' 26 elif direction == 'down': 27 caty += 5 28 if caty == 220: 29 direction = 'left' 30 elif direction == 'left': 31 catx -= 5 32 if catx == 10: 33 direction = 'up' 34 elif direction == 'up': 35 caty -= 5 36 if caty == 10: 37 direction = 'right' 38 39 DISPLAYSURF.blit(catImg, (catx, caty)) 40 41 for event in pygame.event.get(): 42 if event.type == QUIT: 43 pygame.quit() 44 sys.exit() 45 46 pygame.display.update() 47 fpsClock.tick(FPS)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。