pygame.error: Couldn't open imageackground.png


我正在学习python,编了一个类似于飞机大战的程序,。pygame包已经加载,这句background = pygame.image.load('background.png').convert()报错误:pygame.error: File is not a Windows BMP file。不知这种错误怎么解决? 下面是代码:============================================================

!/usr/bin/env python

import pygame import sys import traceback from pygame.locals import * from pygame.image import *

pygame.init() pygame.mixer.init()

bg_size = width, height = 1280,720 screen = pygame.display.set_mode(bg_size) pygame.display.set_caption("UFO")

background = pygame.image.load('./images/background.png').convert()

play music

pygame.mixer.music.load("sound/Tobu - Infectious.ogg") pygame.mixer.music.set_volume(0.2)

def main(): pygame.mixer.music.play(-1)

clock = pygame.time.Clock()

running = True

while running: 
    for event in pygame.event.get():
        if event.type == Quit:
            pygame.quit()
            sys.exit()


    screen.blit(background,(0,0))

    pygame.display.flip()

    clock.tick(60)

if name== " _main _": try: main() except SystemExit: pass except: traceback.print_exc() pygame.quit() input()

  • 目前还没有回复
添加一条新回复
登录 或者 注册 后发表回复