我已经谈到了在python上创建空间入侵者的问题。这是我的密码。我有一个回溯错误:
File "C:\Users\Deadl\Desktop\py4e\Python Crash Course 5\spaceinvader.py",
line 27, in <module> run_game()
File "C:\Users\Deadl\Desktop\py4e\Python Crash Course 5\spaceinvader.py",
line 14, in run_game
ship = Ship(screen)
File "C:\Users\Deadl\Desktop\py4e\Python Crash Course 5\ship.py",
line 7, in __init__
self.image = pygame.image.load('images/ship.bmp')
pygame.error: Unsupported image format
有人能帮我吗?我已经检查了我的飞船和设置,它们都正常。我在我的空间入侵文件夹中创建了一个图像文件夹,其中ship图像为ship.bmp
import sys
import pygame
from settings import Settings
from ship import Ship
def run_game():
#Initialize the game and creates a screen object.
pygame.init()
ai_settings = Settings()
screen = pygame.display.set_mode(
(ai_settings.screen_width, ai_settings.screen_height))
pygame.display.set_caption("Alien Invasion")
# Make a ship.
ship = Ship(screen)
# Start the main loop for the game.
while True:
#Watch for keyboard and mouse events.
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
# Redraw the screen during each pass through the loop.
screen.fill(ai_settings.bg_color)
ship.blitme()
# Make the most recently drawn screen visible.
pygame.display.flip()
run_game()
目前没有回答
相关问题 更多 >
编程相关推荐