如果有帮助,我可以通知我已将文件保存在与图像相同的目录中。 此外,代码给出了以下错误:
Traceback (most recent call last):
File "/home/pi/platform/platformer.py", line 11, in <module>
sun_img = pygame.image.load('home/pi/platform/sun.png')
pygame.error: Couldn't open home/pi/platform/sun.png
这是我写的代码:
import pygame
from pygame.locals import *
pygame.init()
screen_width = 1000
screen_height = 1000
tile_size = 200
screen = pygame.display.set_mode((screen_width, screen_height))
sun_img = pygame.image.load('home/pi/platform/sun.png')
bg_img = pygame.image.load('home/pi/platform/background.jpg')
run = True
while run:
screen.blit(bg_img, (0, 0))
screen.blit(sun_img, (100, 100))
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.display.update()