1

嗨,经过大量研究,我找不到答案。

运行 mac osx 10.8.4 python 2.7.5 和 pygame 1.9.2。

所有模块都在 pygame 的构建中找到,并且在运行时重新安装并不能解决问题:

import pygame
import math
import random

black = (0,0,0)
red = (255,0,0)
white = (255,255,255)
blue = (0,0,255)
green = (0,255,0)

pygame.init()

print pygame.image.get_extended()
size = (1000,700)
screen = pygame.display .set_mode(size)

pygame.display.set_caption("My game")

done = False

clock = pygame.time.Clock()

background_image = pygame.image.load("red_x.png").convert()

while done == False:
     # ALL EVENT PROCESSING SHOULD GO BELOW THIS COMMENT
    for event in pygame.event.get():
        if event.type == pygame.QUIT: 
            done = True


    # ALL EVENT PROCESSING SHOULD GO ABOVE THIS COMMENT


    # ALL GAME LOGIC SHOULD GO BELOW THIS COMMENT

    # ALL GAME LOGIC SHOULD GO ABOVE THIS COMMENT


    # ALL CODE TO DRAW SHOULD GO BELOW THIS COMMENT
    screen.fill(black)

    screen.blit(background_image,[0,0])
    # ALL CODE TO DRAW SHOULD GO ABOVE THIS COMMENT
    pygame.display.flip()  

    clock.tick(20)

pygame.quit()

我得到一个文件不是有效的 Windows BMP 错误。 pygame.images.get_extended()返回 0

try:
   import SDL_image
   print "Loaded SDL_image"
except:
   print "Failed to import SDL_image"

try:
   import libpng
   print "Loaded libpng"
except:
   print "Failed to import libpng"

返回两个失败的导入消息。我认为这就是我在搜索这个时看到的所有测试,他们的所有解决方案都不起作用。

4

1 回答 1

1

我有同样的问题,但我设法解决它安装以下版本的 Pygame: http: //pygame.org/ftp/pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg

于 2013-07-24T11:45:00.627 回答