甚至无法在黑屏上加载pygame中的图片

  • 本文关键字:pygame 加载 python pygame
  • 更新时间 :
  • 英文 :


我正在尝试在pygame中跳跃和跑步,但我仍然是初学者,所以我有一些问题。我现在遇到的问题只是我的"英雄.bmp"不会打开并打印在我的窗户上,但是它没有显示错误,所以我不知道该怎么办。

import pygame, sys
pygame.init()
screen = pygame.display.set_mode((640, 480))
screen.fill((0,0,0))
try:
    player = pygame.image.load('hero.bmp').convert()
except:
    print "please define file 'hero.bmp'"
    sys.exit(1)
playerpos = player.get_rect()
clock = pygame.time.Clock()

您加载了图像,但实际上并未将它们添加到屏幕。

将 "screen.blit(player, (0,0)) " 添加到您的代码中。

这应该将您的玩家图像加载到 0,0。

祝你好运!

最新更新