0
我想了解为什么当我创建我的类的实例图片该文件将不会加载。我已经把文件cartizzle.png在同一个目录,但我不断收到一条错误消息:错误:无法打开cartizzle.png麻烦上传图像到pygame
class Picture():
def __init__(self, location, filename):
self.x = location[0]
self.y = location[1]
self.filename = filename
def draw(self):
pygame.init()
surface_sz = 500
main_surface = pygame.display.set_mode((surface_sz, surface_sz))
while True:
ev = pygame.event.poll()
if ev.type == pygame.QUIT:
break
elif ev.type == pygame.KEYDOWN and ev.key == pygame.K_q:
break
main_surface.fill((0,200,255))
main_surface.blit(self.filename, (self.x, self.y))
pygame.display.flip()
pygame.quit()
pic_inst = Picture((150,200), pygame.image.load("cartizzle.png"))
pic_inst.draw()