user69910
user69910

Reputation: 1003

Pygame not working properly on ubuntu

My pygame code

bif="images.jpg"
mif="point.png"
import pygame, sys
from pygame.locals import *

pygame.init()
screen=pygame.display.set_mode((640,360),0,32)
background=pygame.image.load(bif).convert()
mouse_c=pygame.image.load(mif).convert_alpha()
while True:
        for event in pygame.event.get():
                if event.type == QUIT:
                        pygame.quit()
                        sys.exit()
        screen.blit(background, (0,0))

Error message

Traceback (most recent call last):
  File "game.py", line 8, in <module>
    background=pygame.image.load(bif).convert()
pygame.error: File is not a Windows BMP file

The Same Code Works on different machine but doesn't works on my machine .

Can anyone please help me to solve that problem

How Can I uninstall whole python from my ubuntu machine and than reinstall.

Upvotes: 0

Views: 544

Answers (1)

trevorKirkby
trevorKirkby

Reputation: 1897

Pygame usually loads png files. Several other filetypes will not work. Jpeg will not always be supported. If you want to be absolutely sure that the image will load properly, use an uncompressed bitmap format, but png should work. You could convert the jpg file to png format in any number of ways, for example using an image editor to save it in a different format, or just downloading format conversion software online. If you load png files only, there will be no error.

Upvotes: 1

Related Questions