I am loading an image in python what I think is proper but it still doesn’t display. I don’t know if the image is too big or what.
import pygame
import math
pygame.display.init()
window = pygame.display.set_mode((600, 500))
mapImg = pygame.image.load("mapoftheusa.bmp")
done = False
while not done:
window.fill((0,0,0))
evtList = pygame.event.get()
for evt in evtList:
if evt.type == pygame.QUIT:
done = True
window.blit(mapImg, (0,0)) #<<will not blit
pygame.quit()
You forgot to add a call to
pygame.display.update()right afterwindow.blit(mapImg, (0,0)).So, your complete code should be:
pygame.display.update()updates the window (screen) with your drawings. If you dont call it you will not see anything at all.pygame.display.flip()also works, but it should be used when double buffering or hardware surfaces are being used.Also, I think it is better to initialize pygame by calling
pygame.init()as this will initialize all of its modules including the display.