Skip to content
Sign upLog in
← Back to Community
how to load image
Profile icon
MagnusFrid

i want to load a png-file into my pygame and also a background.

Answered by lynnlo [earned 5 cycles]
View Answer
Voters
Profile icon
DSAJoshua0107
Profile icon
ChrisKraaijevel
Profile icon
MagnusFrid
Comments
hotnewtop
Profile icon
lynnlo

To load the image use image = pygame.image.load("Julstrumpa.png")
To display it on the screen use screen.blit(image,(0,0)) inside a loop.

Profile icon
RookiesNCreamN

import pygame

clock = pygame.time.Clock()

from pygame.locals import *
pygame.init()

pygame.display.set_caption('Pygame Window')

Window_Size = (400, 400)

screen = pygame.display.set_mode(Window_Size, 0, 32)

player_image = pygame.image.load('download (1).png')

while True:

screen.blit(player_image, (50, 50)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit()

pygame.display.update()
clock.tick(60)