You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run = True
while run:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
break
draw(window, background, bg_image)
pygame.quit()
quit()
if name == 'main':
main(window)`
John
The text was updated successfully, but these errors were encountered:
Pygame version 2.6; Python version: 3.12.3
Trying to load a PNG file generates the following error:
File "/home/john/Pygame/Platform_Game/game.py", line 20, in get_background
image = pygame.image.load(os.path.join('assets', 'Background'), name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pygame.error: Unsupported image format
Image attached
The troublesome line of code in bold below.
`import os
import random
import math
import pygame
from os import listdir
from os.path import isfile, join
pygame.init()
pygame.display.set_caption('Platform Game')
BG_COLOR = (255, 255, 255)
WIDTH, HEIGHT = 1000, 800
FPS = 60
PLAYER_VEL = 5
window = pygame.display.set_mode((WIDTH, HEIGHT))
def get_background(name):
image = pygame.image.load(os.path.join('assets', 'Background'), name)
_, _, width, height = image.get_rect()
tiles = []
def draw(window, background, bg_image):
for tile in background:
window.blit(bg_image, tile)
def main(window):
clock = pygame.time.Clock()
background, bg_image = get_background('Blue1.png')
if name == 'main':
main(window)`
John
The text was updated successfully, but these errors were encountered: