Pygame.error Unsupported Image Format
running Python 3.3.0 with pygame '1.9.2pre', following a tutorial, new to python, honestly cant see where i've gone wrong, looks the same as on the tutorial, however it is 4 years
Solution 1:
I would assume the pygame window is not shutting due to the error in your code. You can exit the python shell to exit the pygame window, but the error is the main issue here.
If you're importing images like so, make sure the images are in the same folder or location as your .py file I don't understand where you got mouse_r out of.
Try this:
import pygame, sys
from pygame.localsimport *
pygame.init()
screen = pygame.display.set_mode((1100,750),0,32)
background = pygame.image.load("bg.jpg").convert()
mouse_c = pygame.image.load("man.jpg").convert_alpha()
Running = Truewhile Running:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
Running = False
sys.exit()
break
screen.blit(background,(0,0))
x,y = pygame.mouse.get_pos()
x -= screen.get_width()/2
y -= screen.get_height()/2
screen.blit(mouse_c,(x,y))
pygame.display.update()
Solution 2:
Perhaps you've used the wrong variable name here:
x,y = pygame.mouse.get_pos()
x -= mouse_r.get_width()/2
y -= mouse_r.get_height()/2
screen.blit(mouse_r,(x,y))
I've watched the same tutorial before and it seems that mouse_r
should be mouse_c
.
Edit:
Try using the full directory path name while loading the images:
import os
bif = os.getcwd() + "\\bg.jpg"
mif = os.getcwd() + "\\man.jpg"
Post a Comment for "Pygame.error Unsupported Image Format"