Reputation: 97
I'm creating a game, and I've made a world map image using paint.NET. I saved it as a JPEG file and am trying to load and blit it to a Pygame frame. Here is my code:
import pygame
import sys
from pygame.locals import *
Surface = pygame.display.set_mode ((1000, 775)), 0, 32)
pygame.display.set_caption ('World Map')
white = (255, 255, 255)
pygame.image.load ('WorldMap.jpg')
while True:
Surface.fill (white)
WorldMap.blit(Surface, (900, 675))
for event in pygame.event.get ():
if event.type == QUIT:
pygame.quit ()
sys.exit(0)
pygame.display.update()
My error is that it tells me that it cannot load WorldMap.jpg
Upvotes: 0
Views: 144
Reputation: 4449
In the code you posted, the image isn't assigned to a variable and the blitting is backwards:
pygame.image.load ('WorldMap.jpg')
while True:
Surface.fill (white)
WorldMap.blit(Surface, (900, 675))
should be:
WorldMap = pygame.image.load('WorldMap.jpg')
while True:
Surface.fill(white)
Surface.blit(WorldMap, (900, 675))
Upvotes: 2
Reputation: 52381
Try specifying a full path to the jpg file.
If it still fails, please update your question to include the full error you get.
Upvotes: 0
Reputation: 4663
For whatever reason it isn't loading the image. Here are some steps you can take to attempt to resolve this issue:
Beyond this I cannot be of much help without seeing the entire error and knowing what you found in each of these steps.
Upvotes: 0