1

I'm trying to run this code:

import pygame
import os

WIDTH, HEIGHT = 900, 500
WIN = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("First Game!")

WHITE = (255, 255, 255)
FPS = 60


YELLOW_SPACESHIP_IMAGE = pygame.image.load(
    os.path.join('Assets', 'spaceship_yellow.png'))

RED_SPACESHIP_IMAGE = pygame.image.load(
    os.path.join('Assets', 'spaceship_red.png'))


def draw_window():
    WIN.fill(WHITE)
    WIN.blit(YELLOW_SPACESHIP_IMAGE, (300, 100))
    pygame.display.update()

def main():
    clock = pygame.time.Clock()
    run = True
    while run:
        clock.tick(FPS)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                run = False


        draw_window()

if __name__ == "__main__":
    main()

But it gave me this error:

Traceback (most recent call last):
  File "/home/pi/Desktop/lalogame/main.py", line 13, in <module>
    os.path.join('/home/pi/Desktop/lalogame/Assets', 'spaceship_yellow.png'))
pygame.error: File is not a Windows BMP file

I'm confused because I tried diferent things like used the convert function, algo reinstall the pygame. Basically the code is from a youtube begginers on pygame nothig really hard, but working with images is when the ploblems came. I need some help please.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • 1
    Does this answer your question? [Pygame Error: File is not a windows BMP file](https://stackoverflow.com/questions/28194070/pygame-error-file-is-not-a-windows-bmp-file) – ARK1375 Jun 18 '21 at 20:22
  • Try adding a `pygame.init()` *before* using any of the modules other functions. – martineau Jun 18 '21 at 21:30
  • Which pygame version do you use? It seems that your system can only load BMP files but not PNG files. – Rabbid76 Jun 19 '21 at 07:20
  • I already solve it, I think the problem was over the update or trying to install again, I try everything that I saw here, but I try to erase the OS of Raspberry Pi and Setup from zero. Now is working. –  Jun 19 '21 at 15:46
  • This is the answer is needed to install again: [Solved](https://stackoverflow.com/a/68215609/16239103) –  Jul 01 '21 at 20:15

0 Answers0